O'Reilly logo

Unix in a Nutshell, 4th Edition by Arnold Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required