我正在尝试将驱动器上的部分文件列表复制到另一个驱动器上的某个位置.要复制的文件列表是我试图提供给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/ '{}' \;
这个question接近但不完全.有什么建议?
解决方法:
这只是为你做的伎俩:
cat file_list.txt | xargs -I {} cp {} /destination/dir/path