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:
pi@raspberrypi ~ $ 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.
- A find Tutorial and Primer, by Daniel Miessler
- A Unix/Linux “find” Command Tutorial, by Wayne Pollock
- The GNU Findutils manual
Page last edited February 20, 2015
Text editor powered by tinymce.