I have a folder (call "folder"), composed of different subfolders ("subfolder1", "subfolder2",...). I would like to remove a list of files in all the subfolder of "folder", while some files are present in all the subfolders!

I currently use :

while read file; do rm "$file"basz.dat; done < ~/folder/subfolder1/list.txt

Unfortunately this do the job just for the current folder. How can I apply the same command to all the subfolders?


Use the following command:

while read file;do find . -type f -name "$file"basz.dat -delete; done < list.txt

This will find all files that whose name match with the ones given in your list.txt in all sub-directories of the current directory and delete them.

  • Exactly what I was searching for! Thank you so much – steve Jul 31 '15 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.