Delete a long list of files
Say you wanna search your filesystem for files matching certain criteria and remove them. Here’s how to do it:
Create a text file containing the list of files you want to remove, e.g. like this:
locate abcd | /bin/grep /usr/local > filelist.txt
Inspect filelist.txt carefully to make sure you’re not removing anything you want to keep. Then remove those files like this:
for i in `cat filelist.txt`; do sudo rm -r $i; done
Advertisement