2015-08-21 39 views
0

我目前正试图递归使用此命令不能递归复制一个隐藏目录 - UNIX

cp -r ../openshiftapp/.openshift . 

它不工作复制一个隐藏目录..什么可以是错误的?

+0

我刚试过,它工作正常。 – Barmar

+0

我现在尝试了'cp -R ../openshiftapp/.openshift .',它工作。不过谢谢。 – ClauCece

+0

是'.openshift'文件还是目录?递归拷贝仅对目录有意义,否则没有任何可递归的内容。 – Barmar

回答

4

在OS X上,你应该使用-R而非-r。手册页(在Snow Leopard 10.6.8上)说:

历史版本的cp实用程序有一个-r选项。该实现支持该选项;然而,它的使用是强烈的不鼓励,因为它不正确地复制特殊文件,符号链接或fifo的。

+0

太棒了!不知道..谢谢! – ClauCece

1

cp命令的递归选项将用于目录而不是文件。该文件指出:

-R, -r, --recursive 
      copy directories recursively 

OSX docs有更多的信息,但不建议在选项可以与文件一起使用。相反,它仍然提到了它们用于复制目录内容:

-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 special files rather than copying them as normal files. 
      Created directories have the same mode as the corresponding source directory, unmodified by the 
      process' umask. 

      In -R mode, cp will continue copying even if errors are detected. 

      Note that cp copies hard-linked files as separate files. If you need to preserve hard links, consider using tar(1), cpio(1), or pax(1) instead. 
+0

您的报价来自GNU cp手册页,而不是OS X. – Barmar

+0

更新了包含OSX相关信息的响应。它仍然适用于'-R'选项用于目录。 – ray

+0

如果源是一个文件,我相信递归选项被忽略,并且它正常地复制文件。但这与这个问题无关,因为他正在复制一个目录。 – Barmar