簡體   English   中英

如何以文件夾及其子文件夾的形式遞歸復制文件作為符號鏈接

[英]How to recursively copy files under a folder and its subfolders as symbolic links

在linux或freebsd中,有沒有辦法將文件夾及其子文件夾下的所有文件復制為符號鏈接? 我需要將數千個文件作為符號鏈接復制到不同的位置,並且只有2-3個配置文件作為實際文件。 我這樣做的原因是,我有十幾個網站具有完全相同的引擎代碼,但配置和外觀不同。 我想將引擎復制為符號鏈接,因此我對原始文件所做的每一項更改也將應用於其他網站。 我無法對引擎文件夾本身進行符號鏈接,因為配置文件位於該文件夾下,我無法逐個復制文件! 因為顯然它不實用。 有什么建議嗎?

您正在尋找的命令是cp -rs /path/to/source dest

請注意,您需要提供源目錄的完整路徑,以便它可以創建絕對符號鏈接。

我不知道這是不是你想要的:(見下面的例子)

dir one is your central "engine"
dir two is one of your website.

kent@ArchT60:/tmp$ tree one two
one
|-- 1.txt
|-- 2.txt
|-- 3.txt
|-- 4.txt
|-- 5.txt
|-- dirA
|   |-- a
|   |-- b
|   `-- c
|-- dirB
`-- dirC
two
|-- myConf_a.conf
|-- myConf_b.conf
|-- myConf_c.conf
|-- myConf_d.conf
`-- myConf_e.conf

kent@ArchT60:/tmp$ ln -s /tmp/one/* /tmp/two/.

kent$  tree -l /tmp/two
/tmp/two
|-- 1.txt -> /tmp/one/1.txt
|-- 2.txt -> /tmp/one/2.txt
|-- 3.txt -> /tmp/one/3.txt
|-- 4.txt -> /tmp/one/4.txt
|-- 5.txt -> /tmp/one/5.txt
|-- dirA -> /tmp/one/dirA
|   |-- a
|   |-- b
|   `-- c
|-- dirB -> /tmp/one/dirB
|-- dirC -> /tmp/one/dirC
|-- myConf_a.conf
|-- myConf_b.conf
|-- myConf_c.conf
|-- myConf_d.conf
`-- myConf_e.conf    

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM