2017-06-21 42 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

相關問題