FIND(1) COMMAND REFERENCE FIND(1)
NAME
find - find files
SYNOPSIS
find pathname-list expression
DESCRIPTION
Find recursively descends the directory hierarchy for each
pathname in the pathname-list (i.e., one or more pathnames)
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, 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 pathname.
-follow type
Always true. This option determines whether symbolic
links to directories will be followed. By default,
symbolic links to directories are followed except when
the directory exists on a different host from the top
directory being searched (see EXAMPLES). The type may
Printed 10/17/86 1
FIND(1) COMMAND REFERENCE FIND(1)
be h or r. The h type says that symbolic links to
directories are not to be followed (in other words,
follow only ``hard'' links). The r type says that
remote directories (via the DFS) are to be followed as
well. Note that if both h and r are given, the r is
ignored, since there is no way to follow a remote
directory without following symbolic 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
filename. 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 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 pathname 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
Printed 10/17/86 2
FIND(1) COMMAND REFERENCE FIND(1)
search starts from '/', a symbolic link to a file has
both type l and the type of the file pointed to by the
symbolic link, except in the case of symbolic links to
nonexistent files.
-user uname
True if the file belongs to the user uname (login name
or numeric user ID).
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 {} \;
The following examples print the names of all files found in
the directory `//stuff/usr/bin' (note that this is a DFS
pathname). Assume that the file `//stuff/usr/bin/other' is
a symbolic link to the directory `//otherhost/bin' (a DFS
reference to a different host). The first command below
will print all filenames in `//stuff/usr/bin' and all
subdirectories, including the filenames in
`//stuff/usr/bin/other'. The second command will not print
the filenames in `//stuff/usr/bin/other'.
find //stuff/usr/bin -print -follow r
find //stuff/usr/bin -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.
[P_WARN] A system error occurred. Execution continues.
Printed 10/17/86 3
FIND(1) COMMAND REFERENCE FIND(1)
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 aruments
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), fs(5).
Printed 10/17/86 4
%%index%%
na:72,53;
sy:125,117;
de:242,1380;
op:1622,1037;2803,2530;5477,388;
ex:5865,867;
fi:6732,181;
rv:6913,514;7571,278;
ca:7849,701;
se:8550,190;
%%index%%000000000175