[英]Copy list of files from one location to another in linux
我正在嘗試將驅動器上的部分文件列表復制到另一個驅動器上的某個位置。 要復制的文件列表是我試圖提供給bash腳本的文本文件以及一些cp和xargs命令但無濟於事。 下面是bash嘗試。
#!/bin/bash
while read line
do
find . -iname "$line" -exec cp '{}' /my/destination/drive \;
done < file_list.txt
文本文件讀作沒有擴展名的文件名,如下所示
my-file001
my-file002
my-file003
我也嘗試過以下嘗試的xargs和pax,也無濟於事。
cat file_list.txt | xargs cp -t /my/destination/drive
和
find . -type f -exec pax -rws'|.*/||' < file_list.txt /my/destination/drive/ '{}' \;
這個問題接近但不完全。 有什么建議?
這只是為你做的伎倆:
cat file_list.txt | xargs -I {} cp {} /destination/dir/path
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.