複製多個檔案 - Linux

Table of Contents

大家好 我要問一下很基本的問題
我知道複製是用cp的指令
cp (-r) /locationA/filename /locationB/filename
這樣

現在我想要問的是

如果我只想要複製這個檔案夾裡面的 特定幾個檔案
要怎麼下指令??

比如說
/locationA/file1
/locationA/file2
/locationA/file3

要複製到
/locationB/file1
/locationB/file2
/locationB/file3

要怎麼下指令?

還是只有一個一個複製這樣子?

上面的例子是三個 可是要是有幾千個 不就複製到手指抽筋...囧

感謝各位大大解答~

--
◢███◣ 真是太令我興奮了,教授BOY~~
█████
█▉◥█◤ 覆蓋一張空白考卷在桌上 結束這學期
██ ◤ \
◤◤╲╰┤ ㊣ justlasai

--

All Comments

Ingrid avatarIngrid2013-08-15
cp /locationA/file* /locationB/ 你是指這個嗎?
Queena avatarQueena2013-08-20
可以一次指定多檔名複製到同一目錄下
Catherine avatarCatherine2013-08-23
cp 檔案A 檔案B 檔案C /locationB/ 就可以了
Mason avatarMason2013-08-26
你可以試著使用rsync --include
Zanna avatarZanna2013-08-27
find $path -name $pattern -exec cp {} $dest \;
Quintina avatarQuintina2013-08-29
-type file
Isabella avatarIsabella2013-08-29
如果你的清單是列在檔案裏面的話可以考慮用awk自動化
Kelly avatarKelly2013-09-02
感謝大大~
Sandy avatarSandy2013-09-03
因為是個別產生的檔案 所以可能會用 CP64前輩的做法
Charlie avatarCharlie2013-09-08
我沒到前輩的程度啦... 我也才踏進這個領域沒多久而已...
Isabella avatarIsabella2013-09-08
弄出個清單 filelist
Daph Bay avatarDaph Bay2013-09-08
for i in `cat filelist`; do cp -p /A/$i /B/; done
Isla avatarIsla2013-09-11
樓上大大的方法也是快又有效XD 我看看要怎麼做一個list
檔案名稱的list
Thomas avatarThomas2013-09-11
喜歡那就繼續惡搞吧. 在 .profile 加入底下幾行
multicopy(){
for i in `cat $1`
do
James avatarJames2013-09-12
cp -p /A/$i /B/
done }
Carol avatarCarol2013-09-14
以後你就可以用 multicopy filelist 來複製了.
Kama avatarKama2013-09-18
再把A,B改成$2,$3,就可以multicopy filelist dirA dirB
Caroline avatarCaroline2013-09-19
感謝樓上 學到可以直接自定義東西在.profile裡:D