Locate Files with Unix ‘find’ Command

I have been working with Unix for some years and have managed to learn a little bit of the find command, but I have always forget the syntax. That is why I am writing these lines to serve as a reminder as well as help for beginners.

Example 1: List all Python .pyc files in my current directory, including sub directories:

find . -name “*.pyc” -print


  1. The wildcards after the -name flag must be wrapped in double quotes and
  2. Users who run BSD systems (including Mac OS X) can omit the -print flag

Example 2: Remove all .tmp files from my USB key (which is mounted at /Volumes/hai_usbkey), including those in sub directories:

find /Volumes/hai_usbkey -name ‘*.tmp’ -delete


  1. We can wrap wildcards with single quotes
  2. The -delete flag tells the find command to remove the files. Please use this command with care since you cannot undo deletion

One thought on “Locate Files with Unix ‘find’ Command

  1. Tim Archer

    Hi All! I also can never remember all the common options to the find command that I use. In case it help you can view my simple writeup at:

    My writeup has one major difference than this blog post in that it describes how to use the execute option to pass the find results to another program (such as grep). Hopefully it helps someone!

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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