Recursively Delete Files With Names Matching String
I previously wrote about recursive grep.
Every now and then you need to delete files with a name that contains a string starting from the current directory and all files below. One way to do this on some Unix-like systems is to use something like...
find . -name \*.pyc -ok rm {} \;
The -ok will prompt you before deleting each file which is the safer but slower way to do it. If you're very sure about the file names you want to delete and don't want to be prompted then use -exec in place of -ok.
find . -name \*.pyc -exec rm {} \;
See also Recursively delete certain files.