In Unix-like and some other operating systems, find
is a command-line utility that searches one or more directory trees of a file system, locates files based on some user-specified criteria and applies a user-specified action on each matched file. The possible search criteria include a pattern to match against the filename or a time range to match against the modification time or access time of the file. By default, find
returns a list of all files below the current working directory.
The related locate
programs use a database of indexed files obtained through find
(updated at regular intervals, typically by cron
job) to provide a faster method of searching the entire file system for files by name.
find
appeared in Version 5 Unix as part of the Programmer's Workbench project, and was written by Dick Haight alongside cpio, which were designed to be used together.
The three options control how the find
command should treat symbolic links. The default behaviour is never to follow symbolic links. This can be explicitly specified using the -P flag. The -L flag will cause the find
command to follow symbolic links. The -H flag will only follow symbolic links while processing the command line arguments. These flags are not available with some older versions of find
.
At least one path must precede the expression. find
is capable of interpreting wildcards internally and commands must be constructed carefully in order to control shell globbing.
Expression elements are whitespace-separated and evaluated from left to right. They can contain logical elements such as AND (‑and or ‑a) and OR (‑or ‑o) as well as more complex predicates.