[英]How to read file containing a string and finding it in a directory
I have a file with a list of file names. 我有一个带有文件名列表的文件。 I want to find each of those files and copy it to some directory, is this possible in linux?
我想找到每个文件并将其复制到某个目录,这在Linux中可能吗?
ListOfFileNames.txt
xyz.txt
ags.txt
shd.txt
...
Directory_to_be searched
dsf.txt
xyz.txt
shd.txt
...
Empty_new_directory
So copy xyz.txt, ags.txt, shd.txt and place them in Empty_new_directory 因此,复制xyz.txt,ags.txt,shd.txt并将它们放在Empty_new_directory中
Any help will be appreciated 任何帮助将不胜感激
xargs cp -t /app/dest/ < ListOfFileNames.txt xargs cp -t / app / dest / <ListOfFileNames.txt
Does not work? 不行吗?
Maybe use of find command 也许使用find命令
If there's no nesting, then you can use a simple loop with cp
: 如果没有嵌套,则可以对
cp
使用一个简单的循环:
SOURCE='Directory_to_be_searched'
TARGET='Empty_new_directory'
cat File.txt | while read filename; do
cp "${SOURCE}/${filename}" "${TARGET}/${filename}"
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.