Directory 如何复制包含符号链接的整个目录?
我想将一个完整的目录内容从Directory 如何复制包含符号链接的整个目录?,directory,copy,symlink,freebsd,cp,Directory,Copy,Symlink,Freebsd,Cp,我想将一个完整的目录内容从/home/private\u html/userx/复制到/home/private\u html/usery/中,问题是目录userx包含很少的符号链接,使用cp时只跳过它们(跳过发生,如果符号链接指向文件,如果它指向目录,则只复制整个目录…) 我使用的命令如下所示: # cp -iprv /home/private_html/userx/ /home/private_html/usery/ 有人有办法将目录“原样”复制到其他地方吗?在FreeBSD上,cp没有-
/home/private\u html/userx/
复制到/home/private\u html/usery/
中,问题是目录userx
包含很少的符号链接,使用cp
时只跳过它们(跳过发生,如果符号链接指向文件
,如果它指向目录,则只复制整个目录…)
我使用的命令如下所示:
# cp -iprv /home/private_html/userx/ /home/private_html/usery/
有人有办法将目录“原样”复制到其他地方吗?在FreeBSD上,
cp
没有-r
选项。它确实有-r
,可以满足您的需要:
-R If source_file designates a directory, cp copies the directory and
the entire subtree connected at that point. If the source_file
ends in a /, the contents of the directory are copied rather than
the directory itself. This option also causes symbolic links to be
copied, rather than indirected through, and for cp to create spe‐
cial files rather than copying them as normal files. Created
directories have the same mode as the corresponding source direc‐
tory, unmodified by the process' umask.
罗兰对-R标志的看法是正确的。您还可以使用一对tar进程,这将使您的命令更加独立于系统:
tar -C /home/private_html/userx/ -cpf - . | tar -C /home/private_html/usery/ -epf -