FIND(1) — Silicon Graphics
NAME
find − find files
SYNOPSIS
find path-name-list expression
DESCRIPTION
Find recursively descends the directory hierarchy for each path name in the path-name-list (i.e., one or more path names) seeking files that match a boolean expression written in the primaries given below. By default, symbolic links are not followed (see −follow below). In the descriptions, the argument n is used as a decimal integer where +n means more than n, −n means less than n and n means exactly n.
−name file True if file 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, p, l, or f for block special file, character special file, directory, fifo (a.k.a named pipe), symbolic link, or plain file.
−links n True if the file has n links.
−user uname True if the file belongs to the user uname. If uname is numeric and does not appear as a login name in the /etc/passwd file, it is taken as a user ID.
−group gname True if the file belongs to the group gname. If gname is numeric and does not appear in the /etc/group file, it is taken as a group ID.
−size n[ck] True if the file is n blocks long (512 bytes per block). If n is followed by a c, the size is in characters. If n is followed by a k, the size is in kilobytes.
−atime n True if the file has been accessed in n days.
−mtime n True if the file has been modified in n days.
−ctime n True if the file has been changed in n days.
−inum n True if the file has inode n.
−exec cmd True if the executed cmd returns a zero value as exit status. The end of cmd must be punctuated by an escaped or quoted semicolon. Occurrences of {} are replaced by the current path name, even if they are part of a longer word. Shell meta-characters may be used. The SHELL environment variable, if present, is used to select a shell.
−ok cmd Like −exec except that the generated command line is printed with a question mark first, and is executed only if the user responds by typing y.
−print Always true; causes the current path name to be printed.
−cpio device Write the current file on device in cpio(4) format (5120 byte records).
−newer file True if the current file has been modified more recently than the argument file. The −newer primary may only be used once.
−anewer file True if the current file has been accessed more recently than the argument file. The −anewer primary may only be used once.
−cnewer file True if the current file had its status changed more recently than that of argument file (see chmod(1)). The −cnewer primary may only be used once.
−depth Always true; causes descent of the directory hierarchy to be done so that all entries in a directory are acted on before the directory itself. This can be useful when find is used with cpio(1) to transfer files that are contained in directories without write permission.
−follow Always true; causes find to follow symbolic links (see symlink(2)).
( expression ) True if the parenthesized expression is true (parentheses are special to the shell and must be escaped).
The primaries may be combined using the following operators (in order of decreasing precedence):
1) The negation of a primary ( ! is the unary not operator).
2) Concatentation of primaries (the and operation is implied by the juxtaposition of two primaries).
3) 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.
find / \( −name a.out −o −name ′∗.o′ \) −atime +7 −exec rm {} \;
removes all files named "a.out" or "∗.o" that have not been accessed for a week.
FILES
/etc/passwd
/etc/group
SEE ALSO
chmod(1), cpio(1), sh(1), test(1), stat(2), symlink(2), cpio(4), fs(4).
Version 2.5r1 — October 29, 1986