Use grep to find content in files and move them if they match

前端 未结 9 938
无人共我
无人共我 2020-12-12 13:05

I\'m using grep to generate a list of files I need to move:

grep -L -r \'Subject: \\[SPAM\\]\' .

How can I pass this list to the mv command

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-12 13:23

    Maybe this will work:

    mv $(grep -l 'Subject: \[SPAM\]' | awk -F ':' '{print $1}') your_file
    

提交回复
热议问题