iT邦幫忙

0

如何連檔案的路徑一同複製(linux)

各位大大好:
小弟想要複製個檔案連同資料夾,就是絕對路徑整個都完整複製下來
例如: /var/www/html/aaa.html 將var,www,html,aaa.html這三個資料夾和aaa.html都可copy, 但如果用cp 只會複製aaa.html 路徑那些都不會一同複製
是不是還有其它的指令可以做到? cp的參數apr...那些說明好像都無法達成這需求 orz....

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中
10
Ray
iT邦大神 1 級 ‧ 2011-05-02 14:35:30
最佳解答
<pre class="c" name="code">tar cv /home/catism | tar xv -C /tmp

或是比較保險一點:

<pre class="c" name="code">tar cvf - /home/catism | tar xvf - -C /tmp

前面的 /home/catism 請換成你要拷貝的來源, 例如: /var/www/html/aaa.html
後面的 /tmp 請更換成你拷貝的目的地資料夾.

neo2124 iT邦新手 2 級 ‧ 2011-05-04 09:41:22 檢舉

感謝各位大大熱心的回覆 小弟二種方式都試試看

8
bzbz
iT邦新手 2 級 ‧ 2011-05-02 21:22:54

rsync -avR

bizpro iT邦大師 1 級 ‧ 2011-05-03 10:33:41 檢舉

+1

4
welong
iT邦新手 3 級 ‧ 2011-05-04 14:27:43

cp -a 應該可以 (archie)

sdl iT邦新手 5 級 ‧ 2014-03-25 10:06:21 檢舉

我试过了,在我这里不可以 Linux.

我要發表回答

立即登入回答