命令搜索文件夹中的文件并将文件移动到其他位置

时间:2017-06-21 12:31:44

标签: grep find cp mv

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"

1 个答案:

答案 0 :(得分:0)

尝试这样的事情:

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