1

我想将完整的目录内容从复制/home/private_html/userx/到 中/home/private_html/usery/,问题是该目录userx包含很少的符号链接,并且在使用时cp它只是跳过它们(跳过发生,如果符号链接指向 a file,如果它指向目录,它只需复制整个目录...)。

我使用的命令如下所示:

# cp -iprv /home/private_html/userx/ /home/private_html/usery/

有没有人将目录“原样”复制到其他地方的解决方案?

4

2 回答 2

0

Roland 对 -R 标志的看法是正确的。您还可以使用一对 tar 进程,这将使您的命令更加独立于系统:

tar -C /home/private_html/userx/ -cpf - . | tar -C /home/private_html/usery/ -epf -
于 2013-08-05T17:34:23.980 回答
0

在 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.
于 2013-03-20T00:37:54.563 回答