find is a deceptively powerful tool. Invoked without any options, it'll recursively list all of the files under the current directory and any subdirectories.

...that can be useful, but it's also kind of overwhelming. Most often, you'll want to limit the results by file name or type. For example, to find files starting with "squirrel" followed by any extension, you can do something like:

[email protected] ~ $ find . -name 'squirrel.*'
./python_games/squirrel.png
./python_games/squirrel.py

The -name and -iname (the case-insensitive version) options take shell patterns. If you'd rather use more complex regular expressions, there's a -regex option.

find supports literally dozens of other tests on files, along with actions like deleting files (dangerous!), executing commands with files as parameters, and printing file info according to user-supplied formats.

Further Reading

This guide was first published on Feb 24, 2015. It was last updated on Feb 24, 2015.

This page (Find Files with find(1)) was last updated on Apr 17, 2021.

Text editor powered by tinymce.