Find Cheatsheet

The find command in Linux is immensely useful. Here are some invocations of this command I find useful:

  • List all files and directories under a specified directory:
$ find /usr/include
$ find ../foobar/lib
$ find .

Unlike commands like ls, note that the find command is recursive by default. It will list everything under the specified directory.

  • List only normal files (symbolic links and directories will not be shown):
$ find /usr/include -type f
  • List only symbolic links:
$ find /usr/foobar -type l
  • List only directories:
$ find /usr/foobar -type d
  • Combining two or more types can be done. For example, to list normal files and symbolic links:
$ find /usr/foobar -type f -or -type l
  • List file or directory paths with a wildcard pattern:
$ find /usr/foobar -name "exactly_match_this"
$ find /usr/foobar -name "*.this_extension"
$ find /usr/foobar -name "*some_substring*"
  • List matching a wildcard pattern, but case insensitive:
$ find /usr/foobar -iname "*someblah*"
  • List files whose size is exactly or greater than a specific size:
$ find /usr/foobar -size 10k
$ find /usr/foobar -size +10k
$ find /usr/foobar -size +10M
$ find /usr/foobar -size +10G
  • List empty files:
$ find /usr/foobar -size 0
  • List files and directories newer than the specified file or directory:
$ find /usr/foobar -newer stdio.cpp
  • Do a ls -l on specific files and directories:
$ find /usr/foobar -size +20k -ls
  • Delete files and directories that match:
$ find /usr/foobar -size +20k -delete
  • Note that many of the above operations can be performed by piping the results of find to the immensely useful xargs command. For example, to ls on the results of find:
$ find /usr/foobar -size +20k | xargs ls -l


  • man find
  • The Linux Command Line: A Complete Introduction by William Shotts

Tried with: Ubuntu 16.04


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

This site uses Akismet to reduce spam. Learn how your comment data is processed.