Reputation: 453
I want to collect and move all text files that contain the string “MEDIUM” that are present in my subdirectories on a linux system, to a new folder called MEDIUM_files. I am able to collect all files containing MEDIUM by using
ls *MEDIUM*
but I only want the text files.
All the files contain MEDIUM, but they also differ in number. For example the file name contain different numbers at the end such as "MEDIUM_30_1.txt" or through "MEDIUM_1850_20.txt"
How can I specify a file type as well as containing a string?
Upvotes: 0
Views: 91
Reputation: 800
find . -type f | grep MEDIUM | grep '\.txt$' | xargs -I{} mv {} MEDIUM_files
Upvotes: 1