FIND(1) COMMAND REFERENCE FIND(1) NAME find - find files SYNOPSIS find pathname-list [ expression ] DESCRIPTION The find command recursively descends the directory hierarchy for each path name in the pathname-list (i.e., one or more path names) seeking files that match a boolean expression written in the primaries given 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. The primaries 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). Note that the primaries -print, -follow, -cpio, -prune, -xdev, and - exec are always true and always perform their operations when they are evaluated. 4) Alternation of primaries (`-o' is the or operator). OPTIONS -atime n True if the file has been accessed in n days. -cpio name Write the current file to the file name in cpio(5) format (5120 byte records). -exec command True if the executed command returns a zero value as exit status. The end of the command must be punctuated by a space followed by an escaped semicolon. A command argument `{ }' is replaced by the current path name. -follow type Always true. This option determines whether symbolic links to directories will be followed; by default, symbolic links to directories are followed. The option h type means that symbolic links Printed 5/12/88 1
FIND(1) COMMAND REFERENCE FIND(1) to directories are not to be followed (in other words, follow only ``hard'' links). -group gname True if the file belongs to group gname (group name or numeric group ID). -inum n True if the file has inode number n. -links n True if the file has n links. -mtime n True if the file has been modified in n days. -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 * ). -newer file True if the current file has been modified more recently than the argument file. -ok command Like -exec except that the generated command is written on the standard output, then the standard input is read and the command is executed only upon response y. -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. -print Always true; causes the current path name to be printed. -size n True if the file is n blocks long (512 bytes per block). -type c True if the type of the file is c, where c is b, c, d, f or l for block special file, character special file, directory, plain file, or symbolic link. unless the search starts from /, a symbolic link to a file has both type l and the type of file pointed to by the symbolic link, except in the case of symbolic links to nonexistent files. Printed 5/12/88 2
FIND(1) COMMAND REFERENCE FIND(1) -user uname True if the file belongs to the user uname (login name or numeric user ID). -fstype type True if the file system to which the file belongs is of type type, where type is typically 4.2 or nfs. -prune Always yields true; has the side effect of pruning the search tree at the file. That is, if the current path name is a directory, find will not descend into that directory. -xdev Always true, causes find not to traverse down into a file system different from the one on which current argument path name resides. EXAMPLES To remove all files named a.out or *.o that have not been accessed for a week, type: find / \( -name a.out -o -name '*.o' \) -atime +7 -exec rm {} \; To find all directories in the local file system named src, assuming no src directory is found under any other src directory in the file system, type: find / -fstype 4.2 -name src -prune -print FILES /etc/passwd system user information /etc/group system group information RETURN VALUE [NO_ERRS] Command completed without error. [USAGE] Incorrect command line syntax. Execution terminated. [NP_WARN] An error warranting a warning message occurred. Execution continues. [NP_ERR] An error occurred that was not a system error. Execution terminated. Printed 5/12/88 3
FIND(1) COMMAND REFERENCE FIND(1) [P_WARN] A system error occurred. Execution continues. See intro(2) for more information on system errors. [P_ERR] A system error occurred. Execution terminated. See intro(2) for more information on system errors. CAVEATS Note that the semicolon following the -exec or -ok arguments must be a separate argument. Symbolic links to directories are treated just like normal directories, unless the search starts from /; in order to do this, information about each directory is stored. No directory is ever searched more than once. There is no way to selectively follow symbolic links to directories. The -cpio option does not know about symbolic links. When a symbolic link is encountered, the file pointed to by the link is archived. SEE ALSO cpio(1), du(1), sh(1sh), test(1sh), cpio(5), and fs(5). Printed 5/12/88 4
%%index%% na:240,69; sy:309,213; de:522,1656; op:2178,1291;3781,3328;7421,1193; ex:8614,518; fi:9132,181; rv:9313,491;10116,344; ca:10460,780; se:11240,221; %%index%%000000000180