Removing all files of a certain type

While working on a django project recently, I had to remove all the .pyc files before running syncdb.  These are the kinds of commands I want to know well:

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

This finds all files with a name ending in .pyc, and sends these filenames to the rm command.  Of course, with any operation like this it is a really good habit to run the find command by itself first, and only run the full command when you are sure you will be removing the correct files.


About ehmatthes

Teacher, hacker, new dad, outdoor guy
This entry was posted in programming and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s