[英]“xargs -a file” to copy files to a folder
I am tring to use xargs -a
to read the contents of a file that has a list of filenames in it. 我想使用
xargs -a
来读取其中包含文件名列表的文件的内容。
My directory working in looks like: 我的目录工作方式如下:
backups
file1.bak
file2.bak
file3.bak
bakfiles.txt
File name with filenames in it: bakfiles.txt
其中包含文件名的文件名:
bakfiles.txt
bakfiles.txt contents: bakfiles.txt内容:
file1.bak
file2.bak
file3.bak
So essentially I'm trying to copy file1.bak,file2.bak,file3.bak
into the folder backups
. 所以基本上我正在尝试将
file1.bak,file2.bak,file3.bak
复制到文件夹backups
。 But using the contents of bakfiles.txt
to do so. 但是使用
bakfiles.txt
的内容来做到这一点。
I tried: 我试过了:
xargs -a bakfiles.txt | cp {} backups
But I get the error: 但我得到错误:
cp: cannot stat `{}': No such file or directory
I should mention i also tried: 我应该提一下我也尝试过:
xargs -a bakfiles.txt cp {} backups
And get the error: 并得到错误:
cp: target `file3.bak' is not a directory
这对我来说在Windows 7上使用mks工具包版本的'xargs'
cat bakfiles.txt | xargs -I '{}' cp '{}' backups/'{}'
From the following link i figured it out: 从以下链接我发现:
https://superuser.com/questions/180251/copy-list-of-files https://superuser.com/questions/180251/copy-list-of-files
Heres the command: 继承人命令:
xargs -a bakfiles.txt cp -t backups xargs -a bakfiles.txt cp -t backups
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.