find(1)find(1)NAMEfind - find files
SYNOPSIS
pathname_list [expression]
DESCRIPTION
The command recursively descends the directory hierarchy for each path
name in pathname_list (that is, one or more path names) seeking files
that match a Boolean expression written in the primaries given below.
By default, does not follow symbolic links; see
The Boolean expression is evaluated using short-circuit evaluation.
This means that whenever the result of a Boolean operation (AND or OR)
is known from evaluating the left-hand argument, the right-hand argu‐
ment is not evaluated.
In the descriptions of the primaries, the argument n represents a deci‐
mal integer; means more than n, means less than n, and n means exactly
n.
Options
The command recognizes the following options:
For each symbolic link specified in
pathname_list on the command line, the command evaluates the
file information and file type of the file referenced by the
symbolic link, and not the link itself. If the file referenced
by symbolic link does not exist, the command evaluates the file
information and file type for the link itself. For all sym‐
bolic links not on command line, the command evaluates the file
information and file type for the link itself.
For each symbolic link specified
on the command line in pathname_list or encountered in the file
hierarchy, the command evaluates the file information and file
type of the file referenced by symbolic link, and not the link
itself.
Primaries
The command recognizes the following primaries which are used in the
Boolean expression:
True if the file access time subtracted from the initialized time is
n-1 to n multiples of 24 h. The initialization time shall be a
time between the invocation of the utility and the first access
by that invocation of the utility to any file specified by its
operands. The access time of directories in pathname_list is
changed by itself.
Write the current file on
device in cpio(4) format (5120-byte records). The use of
implies Always true.
True if the time of last change of file status information subtracted
from
the initialization time is n-1 to n multiples of 24 h. The
initialization time shall be a time between the invocation of
the utility and the first access by that invocation of the
utility to any file specified by its operands.
A position-independent term which 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
is used with (see cpio(1)) to transfer files that are contained
in directories without write permission. It is also useful
when using and the modification dates of directories must be
preserved. Always true.
True if the executed
cmd returns a zero value as exit status. The end of cmd must
be punctuated by a semicolon or a plus sign The semicolon and
plus are special to the shell and must be escaped with a back‐
slash When is used, cmd aggregates a set of path names and exe‐
cutes on the set. Any command arguments between the first
occurrence of curly braces and plus sign are ignored. In the
UNIX 2003 environment, indicates end of cmd, only if immedi‐
ately follows The reason for preferring to a is improved per‐
formance. With the the command in executes for each match that
the command finds. However, with the command executes only
once.
Any command argument is replaced by the current path name. cmd
may contain supplementary code set characters.
This example shows the difference between using and Two direc‐
tories each have a file called, Directory has one file:
Directory has three files:
The following commands search for the file named in the direc‐
tories:
When is in the command, executes only once. When is in the
command, executes for each match.
A position-independent term which causes
to follow symbolic links. When following symbolic links, keeps
track of the directories visited so that it can detect infinite
loops; for example, such a loop would occur if a symbolic link
pointed to an ancestor. This expression should not be used
with the Expression. Always true.
A position-independent term which causes
to stop descending any directory whose file system is not of
the type specified by FStype, where FStype is one of or repre‐
senting the CDFS, HFS, JFS (VXFS), or NFS file system type,
respectively.
In this context, mount points inherit the FStype of their par‐
ent directory. This means that when has been specified and
encounters an NFS mount point that is mounted on an HFS file
system, the mount point will be visited but entries below that
mount point will not. It is important to note that when has
been specified, any HFS file systems that are beneath the mount
point of an NFS file system are not traversed. Always true.
True if the file system to which the file belongs is of type
FStype, where FStype is one of or corresponding to the CDFS,
HFS, NFS, or JFS (VXFS) file system type, respectively.
True if the file belongs to the group
gname. If gname is numeric and does not appear in the file, it
is taken as a group ID. The gname operand can be preceded by a
or to modify the comparison of the primaries. If the argument
n represents a decimal integer; means more than n, means less
than n, and n means exactly n.
True if the file serial number (inode number) is
n. Note that file serial numbers are unique only within a
given file system. Therefore, matching file serial numbers
does not guarantee that the referenced files are the same
unless you restrict the search to a single file system.
True if the file is the same physical file as the file specified by
path (i.e., linked to path). This primary is similar to but
correctly detects when a file is hard-linked to path, even when
multiple file systems are searched.
True if the file has
n links.
True if the file physically resides on the local
system. This does not restrict the search to only files which
physically reside on the local system, it merely matches such
files. See
Always true; prints current path name along with its associated statis‐
tics,
which include:
· inode number
· size in kilobytes (1024 bytes)
· protection mode
· number of hard links
· user
· group
· size in bytes
· modification time.
If the file is a special file, the size field will instead con‐
tain the major and minor device numbers. If the file is a sym‐
bolic link, the pathname of the linked-to file is printed pre‐
ceded by `->'.
Identical to
This primary is provided for backward compatibility only. is
preferred over
True if the file modification time subtracted from the initialization
time is
n-1 to n multiples of 24 h. The initialization time shall be a
time between the invocation of the utility and the first access
by that invocation of the utility to any file specified in its
operands.
True if pattern
file matches the last component of the current file name. Pat‐
tern is matched according to Pattern Matching Notation for file
name expansion. Pattern should be escaped (using backslash) or
quoted when is invoked from the shell, to prevent the shell
from expanding any metacharacters. Pattern may contain supple‐
mentary code set characters.
Same as but adds the option to The use of implies Always true.
True if the current file has been modified more recently than the argu‐
ment
file.
True if the indicated time value
(tv1) of the current file is newer than the indicated time
value (tv2) of file. The time values tv1 and tv2 are each
selected from the set of characters:
The time the file was last accessed
The time the inode of the file was last
modified
The time the file was last modified
If the tv2 character is omitted, it defaults to Note that the
option is equivalent to
Syntax examples;
True if the file belongs to a group ID
that is not listed in the group database. See group(4).
True if the file belongs to a user ID
that is not listed in the password database. See passwd(4).
Same as except that the generated command line is printed with a ques‐
tion mark first, and is executed only if the user responds by
typing The form of the affirmative response is locale depen‐
dent: y in the C locale, see on environ(5). The end of cmd
must be punctuated by a semicolon (semicolon is special to the
shell and must be escaped). cmd may contain supplementary code
set characters.
This is a positive-logic version of
A is performed after every directory, unless is successfully
evaluated for that directory. As an example, the following
three commands are equivalent:
Note, however, that is useless if the option has also been
given. Always true.
Same as except the full path (as would be output by is used instead of
just the base name. Note that characters are not treated as a
special case. For example, matches
Causes the current path name to be printed followed by
a newline character. Always true.
Causes the current path name to be printed followed by
a null character. Always true.
In this primary, the argument
mode is used to represent file mode bits. The argument is
identical in format to the mode operand as described in
chmod(1), with the exception that the first character must not
be the operator. When using the symbolic form of mode, the
starting template is assumed to have all file mode bits
cleared.
If the leading minus is omitted, this primary is true when the
file permission bits exactly match the value of mode. Bits
associated with the symbolic attributes (set-user-ID, set-
group-ID) and (sticky bit) are ignored when the minus is omit‐
ted.
If mode is preceded by a minus, this primary is true if all of
the bits that are set in mode are also set in the file permis‐
sion bits. In this case, the bits associated with the symbolic
attributes and are significant.
If the current entry is a directory, cause
to skip that directory. This can be useful to avoid walking
certain directories, or to avoid recursive loops when using
Note, however, that is useless if the option has also been
given. See the description of and the section, below, for more
information. Always true.
True if the file is
n blocks long (512 bytes per block). If n is followed by a the
size is in bytes.
True if the type of the file is
c, where c is one of the following:
Block special file
Character special file
Directory
Regular file
Symbolic link
Mount point
Network special file
FIFO (named pipe)
Socket
True if the file belongs to the user
uname. If uname is numeric and does not appear as a login name
in the file, it is taken as a user ID. The uname operand can
be preceded by a or to modify the comparison of the primaries.
If the argument n represents a decimal integer; means more than
n, means less than n, and n means exactly n.
A position-independent term that causes
to avoid crossing any file system mount points that exist below
starting points enumerated in pathname_list. The mount point
itself is visited, but entries below the mount point are not.
Always true.
True if the parenthesized expression is true.
The spaces are required. Parentheses are special to the shell
and must be escaped, as in and
Primaries can be combined by using the following operators (in order of
decreasing precedence):
Logical AND operator.
True if both of the expressions are true.
Logical OR operator.
True if either or both of the expressions
are true.
Logical NOT operator.
True if expression is not true.
If expression is omitted, or if none of or is specified, is assumed.
The and primaries each evaluate their respective arguments once.
HFS Access Control Lists
The primary enables the user to search for HFS access control list
entries. It is true if the file's access control list matches an
access control list pattern or contains optional access control list
entries (see acl(5)). It has three forms:
Match all files whose access control list includes all
(zero or more) pattern entries specified by
the aclpatt pattern.
Match a file only if its access control list
includes all (zero or more) pattern entries
specified by the aclpatt pattern, and every
entry in its access control list is matched
by at least one pattern entry specified in
the aclpatt pattern.
Match all files containing optional access control
list entries.
The aclpatt string can be given as an operator or short form pattern;
see acl(5).
By default, is true for files whose access control lists include all
the (zero or more) access control list patterns in aclpatt. A file's
access control list can also contain unmatched entries.
If aclpatt begins with the remainder of the string must match all
entries in a file's access control list.
The aclpatt string (by default, or the part following can be either an
access control list or an access control list pattern. However, if it
is an access control list, aclpatt must include at least the three base
entries ((user.%, mode), (%.group, mode), and (%.%, mode)).
As a special case, if aclpatt is the word the primary is true for files
with access control list entries.
JFS Access Control Lists
The primary enables the user to search for JFS access control list
entries. It is true if the file's access control list matches an
access control list pattern or contains optional access control list
entries (see aclv(5)). It has three forms:
Match all files whose access control list includes all
(zero or more) pattern entries specified by
the aclpatt pattern.
Match a file only if its access control list
includes all (zero or more) pattern entries
specified by the aclpatt pattern, and every
entry in its access control list is matched
by at least one pattern entry specified in
the aclpatt pattern.
Match all files containing optional access control
list entries.
By default, is true for files whose access control lists include all
the (zero or more) access control list patterns in aclpatt. A file's
access control list can also contain unmatched entries.
If aclpatt begins with the remainder of the string must match all
entries in a file's access control list.
An aclpatt consists of a type field, an ID field, and a mode field,
separated by colons. Multiple comma-separated aclpatts may be speci‐
fied.
The type field is one of or optionally preceded by and can be abbrevi‐
ated to and respectively. A type field of matches any of the above
types.
The ID field is either a numeric user or group ID, a user or group ID
string from or respectively, or which matches any ID. The ID field can
be mentioned only if the type field matches any of or
The mode field consists of a string of three characters. The first
character is either indicating that read permission is granted; indi‐
cating that read permission is denied; or which matches either state of
read permission. The second character is either or similarly indicat‐
ing the state of write permission; and the third character is either or
indicating the state of execute permission.
As a special case, if aclpatt is the word the primary is true for files
with optional access control list entries.
EXTERNAL INFLUENCES
Environment Variables
If an internationalization variable is not specified or is null, it
defaults to the value of
If is not specified or is null, it defaults to (see lang(5)).
If is set to a nonempty string value, it overrides the values of all
the other internationalization variables.
If any internationalization variable contains an invalid setting, all
internationalization variables default to (see environ(5)).
determines the interpretation of text as single and/or multibyte char‐
acters, the classification of characters as printable, and the charac‐
ters matched by character class expressions in regular expressions.
determines the locale that should be used to affect the format and con‐
tents of diagnostic messages written to standard error and informative
messages written to standard output.
determines the location of message catalogues for the processing of
International Code Set Support
Single- and multibyte character code sets are supported.
EXAMPLES
Here are several examples.
· The following examples show using and options. is a symbolic link
which points to a directory
The following command lists the filenames which are type directo‐
ries. is not printed by default.
The following command uses the option. Because is not found on the
command line, it is not followed and not treated as a directory.
The following command uses the option. Although is not found on the
command line, the option causes all the symbolic links encountered
anywhere in the file hierarchy to be followed.
In the following example, the symbolic link, is on the command line,
so it is followed and recognized as a type
· Search two directories, and for files containing the string and
print the names of the files:
· Remove all files named or that have not been accessed for a week:
Note that the spaces delimiting the escaped parentheses are
required.
· Print a single long listing of all files named in the current direc‐
tory:
Note that the curly braces, before plus sign, are optional.
· Print the names of all files on this machine. Avoid walking direc‐
tories while still printing the mount points:
· Match only local files, and do not examine the contents of any
directory found to be remotely mounted:
This only works correctly if there are no local file systems mounted
on top of remote directories. This example will print all local
files on the system larger than 50 blocks, without wasting time
accessing remote files.
· To get the same effect, but to check for files in local file systems
mounted on remote directories, use:
· Copy the entire file system to a disk mounted on avoiding the recur‐
sive copy problem. Both commands are equivalent (note the use of
instead of
· Copy the root disk to a disk mounted on skipping all mounted file
systems below Note that does not cause to be skipped, even though it
is a mount point. This is because is the starting point and only
affects entries starting points.
· Change permissions on all regular files in a directory subtree to
mode 444, and permissions on all directories to 555:
Note that output from was piped to xargs(1) instead of using the
primary. This is because when a large number of files or direc‐
tories is to be processed by a single command, the primary
spawns a separate process for each file or directory, whereas
xargs collects file names or directory names into multiple argu‐
ments to a single chmod command, resulting in fewer processes
and greater system efficiency. The delimiter for the primary
can be used to achieve the same efficiency.
Access Control List Examples
The following examples are for Access Control Lists.
· Find all files not owned by user that have access control lists with
at least one entry associated with and one entry for no specific
user in group with the read bit on and the write bit off:
· Find all files that have a read bit set in any access control list
entry:
· Find all files that have the write bit unset and execute bit set in
every access control list entry:
· Find all files that have optional access control list entries:
DEPENDENCIES
NFS
The primary is always false for NFS files.
WARNINGS
Because of interoperability goals, does not support archiving files
larger than 2GB or files that have user/group IDs larger than 60,000
(60K). Files with user/group IDs greater than 60K are archived and
restored under the user/group ID of the current process.
AUTHOR
was developed by AT&T and HP.
FILES
Group names
Mount points
User names
SEE ALSOchacl(1), chmod(1), cpio(1), setacl(1), sh(1), test(1), xargs(1),
mknod(2), stat(2), cpio(4), group(4), passwd(4), acl(5), aclv(5), envi‐
ron(5), lang(5), regexp(5).
STANDARDS CONFORMANCEfind(1)