我有一个名为list.txt的文件名列表。
我想将此列表中的文件复制到一个新文件夹中。
我该如何操作?
谢谢!
我有一个名为list.txt的文件名列表。
我想将此列表中的文件复制到一个新文件夹中。
我该如何操作?
谢谢!
cp `cat list.txt` new-folder/
如果您想保留目录结构,请使用以下命令之一(假设使用GNU tar):
cpio -pvdm /destination <list.txt
tar -cf - -F list.txt | tar -C /destination -x
使用循环
while read -r line
do
cp "$line" /destination
done <"file"
循环:
dest="<destination folder>" #keep the quotes
for i in `cat < list.txt` #loop each line of list.txt
do
cp $i $dest #in each loop copy $i, e/a line of list.txt to $dest
echo "Done."
done