2013-01-10 65 views
0

我想從/home/private_html/userx/一個完整的目錄中的內容複製到/home/private_html/usery/,問題是該目錄userx包含幾個符號鏈接,並使用cp時,它只是跳過他們(出現跳過,如果符號鏈接引導到file,在情況下,如果它指向目錄,它只是複製WHOLE目錄而不是...)。如何複製包含符號鏈接的整個目錄?

我用下面看起來命令:

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

有沒有人解決複製目錄「只是因爲它是」到其他地方嗎?

回答

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. 
0

羅蘭是對有關-R標誌。你也可以使用一對焦油進程,這將使你的命令更獨立於系統:

tar -C /home/private_html/userx/ -cpf - . | tar -C /home/private_html/usery/ -epf -