FIND(1) — UNIX Programmer’s Manual
NAME
find − find files
SYNOPSIS
find pathname-list predicate-list expression
DESCRIPTION
Find recursively descends the directory hierarchy one directory at a time, for each pathname in the pathname-list (i.e., one or more pathnames) using the first pathname in the list as the starting point.
You can use find to locate files for which you can remember the name but not the location, or to locate files that fulfill certain criteria.
Find seeks files that match conditions set forth in the predicate-list, and performs actions specified in the expression.
In the predicate-list, the number argument n is used to mean a decimal integer where +n means more than n, −n means less than n and n means exactly n.
The following predicate descriptors are available:
−name filename
True if the filename argument matches the current file name. Normal Shell argument syntax may be used if escaped (watch out for "[", "?" and "*").
−perm onum
True if the file permission flags exactly match the octal number onum (see chmod(1)). If onum is prefixed by a minus sign, more flag bits (017777, see stat(2)) become significant and the flags are compared: (flags&onum)==onum.
−type c True if the type of the file is c, where c is b, c, d or f for block special file, character special file, directory or plain file.
−links n True if the file has n links.
−user uname
True if the file belongs to the user uname (login name or numeric user ID).
−group gname
True if the file belongs to group gname (group name or numeric group ID).
−size n True if the file is n blocks long (512 bytes per block).
−inum n True if the file has inode number n.
−atime n True if the file has been accessed in n days.
−mtime n
True if the file has been modified in n days.
−exec command
True if the executed command returns a zero value as exit status. The end of the −exec and command sequence must consist of a pair of curly braces and an escaped semicolon. With −exec the command argument ’{}’ is necessary to store the current pathname.
−ok command
Like −exec in its syntax, except that the generated command is written on the standard output, then the standard input is read and the command executed only upon response "yes", or y.
−print Always true; causes the current pathname to be printed. Do not terminate this command with curly braces or a semicolon.
−newer file
True if the current file has been modified more recently than the argument file.
The primaries or predicate operators may be combined using the following operators (in order of decreasing precedence):
1) A parenthesized group of primaries and operators (parentheses are special to the Shell and must be escaped).
2) The negation of a primary (’!’ is the unary not operator).
3) Concatenation of primaries (the and operation is implied by the juxtaposition of two primaries).
4) Alternation of primaries (’−o’ is the or operator).
EXAMPLES
find / -perm 755 -exec ls "{}" ";"
will find all files, starting with the root directory, on which the permission levels have been set to 755 (see chmod(1).
With −exec and a command such as ls, it is often necessary to escape the "{}" that stores the current pathname under investigation by putting it in double quotes. It is always necessary to escape the semicolon at the end of an −exec sequence.
Note again that it is also necessary to escape parentheses
" \( " and " \) " used for grouping primaries, by means of a backslash.
FILES
/etc/passwd
/etc/group
SEE ALSO
BUGS
The syntax is painful.
7th Edition — 2/4/82