2017-06-21 88 views
0
I have a text file which has list of file names, I want to search these file names in a folder which has thousands of files and move the matching files to different location on linux. 

有人可以帮助我执行此操作。命令来搜索文件夹中的文件并将文件移动到不同的位置

下面是代码我使用

#!/bin/bash 
file="/home/BILEKJ/Reprocess/data.txt" 
while IFS= read -r line 
do 
    mv "/home/BILEKJ/Reprocess/EDI855/$line" "/home/BILEKJ/Reprocess/Final855" >/dev/null 2>&1 
done <"$file" 
+0

如何 “大” 是*文件名列表*? – RomanPerekhrest

+0

该列表有大约4000个文件名 – user2231076

回答

0

尝试这样的事:

file="data.txt" 
while IFS= read -r line 
do 
     mv "/your/path/$line" "/dest/path" >/dev/null 2>&1 
done <"$file" 
+0

这不起作用,如何从上面的命令中知道从哪个文件读取数据 – user2231076

+0

@ user2231076 .....查看代码块中的第一行,“” data.txt“只是一个例子。 – Kent

+0

是的,我用我的输入文件名作为data.txt,并没有工作 – user2231076

相关问题