开发者

Linux: copy files which are listed in a txt file from a directory (with subdirectories) to a specified folder

I have开发者_开发技巧 a txt file with only names of files in it. I.e. "999000 999008 999021" etc. They correspond to files that I have with the extension *.source I.e. 999000.source 999008.source 999021.source. These files exist within different sub-directories beneath a master directory. How would I go about copying the files listed in the txt file to another specified folder using commands in Linux?

Thanks, Jake


Provided there are no spaces in the file names:

(for fn in $(cat filenames.txt); do
    find "$master_dir" -type f -name "$fn.source"
done) |tar -cT - |(cd "$new_dir" && tar x)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜