find(1) find(1) NAME find - find files SYNOPSIS find path-name-list [ expression ] DESCRIPTION find recursively descends the directory hierarchy for each pathname in the path-name-list (that is, one or more pathnames) seeking files that match a boolean expression written in the primaries given below. If the expression does not contain at least one of -print, -ok, or -exec, including the case of a null expression, a -print is implicit. 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. Valid expressions are: -name file True if file matches the current filename. Normal shell argument syntax can be used if escaped (watch out for [, ?, and *). -perm [-]mode True if the file permission flags exactly match the file mode given by mode which can be an octal number or a symbolic expression of the form used in chmod(1)). If mode is prefixed by a minus sign, only the bits that are set in mode are compared with the file permission flags, and the expression evaluates true if they match. -type c True if the type of the file is c, where c is b, c, d, l, p, f, or s for block special file, character special file, directory, symbolic link, fifo (a.k.a named pipe), plain file, or socket respectively. -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. -nouser True if the file belongs to a user not in the /etc/passwd file. -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. -nogroup True if the file belongs to a group not in the /etc/group file. -proj projname True if the file has a project ID of projname. If projname is numeric and does not appear in the /etc/projid file, it is taken as a project ID. -noproj True if the file has a project ID not in the /etc/projid file. -size [+-]n[c] True if the file is n blocks long (512 bytes per block). If n is followed by a c, the size is in characters. -inum n True if n is the inode number of the file. -atime [+-]n True if the file was accessed n days ago. The definition of n days ago is any time within the interval beginning exactly n*24 hours ago and ending exactly (n-1)*24 hours ago. The + and - prefixes signify more or less than n days ago, respectively, thus +n means more than n*24 hours ago, and -n means less than n*24 hours ago. (See stat(2) for a description of which file operations change the access time of a file.) The access time of directories in path-name-list is changed by find itself. -mtime [+-]n True if the file was modified n days ago. See -atime for definition of "n days ago". (See stat(2) for a description of which file operations change the modification time of a file.) -ctime [+-]n True if the file was changed n days ago. See -atime for definition of "n days ago". (See stat(2) for a description of which file operations change the change time of a file.) -exec cmd True if the executed cmd returns a zero value as exit status. The end of cmd must be punctuated by an escaped semicolon. A command argument {} is replaced by the current pathname. -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 pathname to be printed. -cpio device Always true; write the current file on device in cpio(1) format (5120-byte records). find -cpio issues a warning if it encounters a file larger than two gigabytes. cpio(1) must be used to archive files of this size. -ncpio device same as -cpio option except archive is written in the cpio -c format. -newer file True if the current file has been modified more recently than the argument file (see stat(2) for a description of which file operations change the modification time of a file). -anewer file True if current file has been accessed more recently than the argument file (see stat(2) for a description of which file operations change the access time of a file). -cnewer file True if current file has been changed more recently than the argument file (see stat(2) for a description of which file operations change the change time of a file). -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. -prune Always true; do not examine any directories or files in the directory structure below the pattern just matched. If the current pathname is a directory, find does not descend into that directory, provided -depth is not also used. -mount Always true; restricts the search to the filesystem containing the current element of the path-name-list. -fstype type True if the filesystem to which the file belongs is of type type. -local True if the file physically resides on the local system; causes the search not to descend into remotely mounted filesystems. -follow Always true; causes the underlying file of a symbolic link to be checked rather than the symbolic link itself. -label label True if the file label and label satisfy the mac_equal label equality relationship. See dominance(5). -xlabel label True if the file label is exactly identical to label. See dominance(5). -dominates label True if the file label dominates label. See dominance(5). -dominated label True if the file label is dominated by label. See dominance(5). \( expression \) True if the parenthesized expression is true (parentheses are special to the shell and must be escaped). The primaries can be combined using the following operators (in order of decreasing precedence): + The negation of a primary (! is the unary not operator). + Concatenation of primaries (the and operation is implied by the juxtaposition of two primaries). + Alternation of primaries (-o is the or operator). EXAMPLES To remove all files named a.out or *.o that have not been accessed for a week: find / \( -name a.out -o -name '*.o' \) -atime +7 -exec rm {} \; To display all character special devices on the root filesystem except those under any dev directory: find / -mount \( -type d -name dev -prune \) -o -type c -print FILES /etc/passwd UID information supplier /etc/group GID information supplier /etc/projid Project ID information supplier SEE ALSO chmod(1), cpio(1), sh(1), test(1), stat(2), umask(2), efs(4), xfs(4), dominance(5). BUGS find / -depth always fails with the message: find: stat failed: : No such file or directory find relies on a completely correct directory hierarchy for its search. In particular, if a directory's '..' is missing or incorrect, find fails at that point and issue some number of these messages: stat failed: -depth and -prune do not work together well. Page 4