Name
find
Synopsis
find [options
]pathname(s) condition(s)
An extremely useful command for finding particular groups of
files (numerous examples follow this description). find descends the directory tree
beginning at each pathname and locates files
that meet the specified conditions. At least
one pathname must be specified. The most
useful conditions include -print
,
-name
, and -type
(for general
use), -exec
and -size
(for
advanced users), and -mtime
and
-user
(for administrators).
On very old systems, you must supply at least one
condition. If you don’t, find traverses the
pathnames but doesn’t produce any output.
Therefore, for highest portability, always provide
-print
.
Conditions may be grouped by enclosing them in \( \)
(escaped parentheses), negated
with !
(use \!
in the C shell), given as
alternatives by separating them with -o
, or
repeated (adding restrictions to the match; usually only for
-name
, -type
, and
-perm
).
The find command can often be combined with the xargs command when there are too many files for naming on the command line. (See xargs.)
Tip
find is yet another example of a Unix command that has a core set of common abilities, with many system-specific extensions. Take careful note of which systems support which conditions.
Solaris and Mac OS X Options
-
-H
Only for files named on the command line, follow symbolic links, working with the information about the linked-to file, instead of the symbolic link itself.
-
-L
For all symbolic links, follow the link, working with the ...
Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.