I was having some trouble with a python app and needed to clear some cached, precompiled versions of some of the files in the app. I had a hunch the find command might be useful, so I looked at the man doc. Turns out it was very useful.

find takes a few arguments. The first (mandatory) argument is the path to search. In my case, it was the current directory: . . I also used an optional argument, an expression to filter out all files other than those ending in pyc. Here’s what I ended up with:

find . -name "*.pyc" | xargs rm

For some reason, I needed to put quotes around the *.pyc, otherwise I got the error:

find: paths must precede expression

Also, I added | xargs rm, piping find’s output into xargs, which allows you to apply another method (in this case, rm) to each line. This basically deletes anything in the current directory or any subdirectories named .pyc. Be careful!

Finally, a quick google search brought me to this page that has lots of other good examples: http://www.wagoneers.com/UNIX/FIND/find-usage.html