在Linux中将文件列表从一个位置复制到另一位置 [英] Copy list of files from one location to another in linux
本文介绍了在Linux中将文件列表从一个位置复制到另一位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将驱动器上的部分文件列表复制到另一个驱动器上的某个位置.要复制的文件列表在一个文本文件中,我尝试将其提供给bash脚本以及一些cp和xargs命令,但无济于事.下面是bash尝试.
I'm attempting to copy a partial list of files on a drive to a location on another drive. The list of files to copy is in a text file that I've attempted to supply to a bash script as well as some cp and xargs commands but to no avail. Below is the bash attempt.
#!/bin/bash
while read line
do
find . -iname "$line" -exec cp '{}' /my/destination/drive \;
done < file_list.txt
文本文件读取为没有扩展名的文件名,如下所示
The text file reads as filenames with no extensions, like below
my-file001
my-file002
my-file003
我还尝试了xargs和pax,但以下尝试均无济于事.
I've also tried xargs and pax with the below attempts, also to no avail.
cat file_list.txt | xargs cp -t /my/destination/drive
和
find . -type f -exec pax -rws'|.*/||' < file_list.txt /my/destination/drive/ '{}' \;
此问题已接近但不完全的.有什么建议吗?
This question came close but not quite. Any suggestions?
推荐答案
这将为您解决问题:
cat file_list.txt | xargs -I {} cp {} /destination/dir/path
这篇关于在Linux中将文件列表从一个位置复制到另一位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文