version 1.15, 1997/11/13 08:30:33 |
version 1.16, 1998/09/26 19:54:43 |
|
|
.Op Ar file ... |
.Op Ar file ... |
.Ar expression |
.Ar expression |
.Sh DESCRIPTION |
.Sh DESCRIPTION |
.Nm Find |
.Nm find |
recursively descends the directory tree for each |
recursively descends the directory tree for each |
.Ar file |
.Ar file |
listed, evaluating an |
listed, evaluating an |
|
|
.Pp |
.Pp |
.Bl -tag -width Ds |
.Bl -tag -width Ds |
.It Fl H |
.It Fl H |
The |
Causes the file information and file type (see |
.Fl H |
.Xr stat 2 ) |
option causes the file information and file type (see |
|
.Xr stat 2 ) , |
|
returned for each symbolic link encountered on the command line to be |
returned for each symbolic link encountered on the command line to be |
those of the file referenced by the link, not the link itself. |
those of the file referenced by the link, not the link itself. |
If the referenced file does not exist, the file information and type will |
If the referenced file does not exist, the file information and type will |
be for the link itself. File information of all symbolic links not on |
be for the link itself. File information of all symbolic links not on |
the command line is that of the link itself. |
the command line is that of the link itself. |
.It Fl d |
.It Fl d |
The |
Causes |
.Fl d |
|
option causes |
|
.Nm find |
.Nm find |
to perform a depth\-first traversal, i.e. directories |
to perform a depth\-first traversal, i.e. directories |
are visited in post\-order and all entries in a directory will be acted |
are visited in post\-order and all entries in a directory will be acted |
|
|
Note, the default is |
Note, the default is |
.Ar not |
.Ar not |
a breadth\-first traversal. |
a breadth\-first traversal. |
.It Fl f |
.It Fl f Ar file |
The |
Specifies a file hierarchy for |
.Fl f |
|
option specifies a file hierarchy for |
|
.Nm find |
.Nm find |
to traverse. |
to traverse. |
File hierarchies may also be specified as the operands immediately |
File hierarchies may also be specified as the operands immediately |
following the options. |
following the options. |
.It Fl h |
.It Fl h |
The |
Causes the file information and file type (see |
.Fl h |
|
option causes the file information and file type (see |
|
.Xr stat 2 ) , |
.Xr stat 2 ) , |
returned for each symbolic link to be those of the file referenced by the |
returned for each symbolic link to be those of the file referenced by the |
link, not the link itself. |
link, not the link itself. |
If the referenced file does not exist, the file information and type will |
If the referenced file does not exist, the file information and type will |
be for the link itself. |
be for the link itself. |
.It Fl X |
.It Fl X |
The |
Permit |
.Fl X |
|
option is a modification to permit |
|
.Nm |
.Nm |
to be safely used in conjunction with |
to be safely used in conjunction with |
.Xr xargs 1 . |
.Xr xargs 1 . |
|
|
.Xr xargs , |
.Xr xargs , |
a diagnostic message is displayed on standard error, and the file |
a diagnostic message is displayed on standard error, and the file |
is skipped. |
is skipped. |
The delimiting characters include single (`` ' '') and double (`` " '') |
The delimiting characters include single (``''') and double (``"'') |
quotes, backslash (``\e''), space, tab and newline characters. |
quotes, backslash (``\e''), space, tab and newline (``\en'') characters. |
As an alternative, the |
As an alternative, the |
.Fl print0 |
.Fl print0 |
function may be used safely in conjunction with the |
function may be used safely in conjunction with the |
.Fl 0 |
.Fl 0 |
argument to |
argument to |
.Xr xargs 1 |
.Xr xargs 1 . |
.It Fl x |
.It Fl x |
The |
Prevents |
.Fl x |
|
option prevents |
|
.Nm find |
.Nm find |
from descending into directories that have a device number different |
from descending into directories that have a device number different |
than that of the file from which the descent began. |
than that of the file from which the descent began. |
|
|
.Ar utility |
.Ar utility |
returns a zero value as its exit status. |
returns a zero value as its exit status. |
Optional arguments may be passed to the utility. |
Optional arguments may be passed to the utility. |
The expression must be terminated by a semicolon (``;''). |
The expression must be terminated by a semicolon (`;'). |
If the string ``{}'' appears anywhere in the utility name or the |
If the string ``{}'' appears anywhere in the utility name or the |
arguments it is replaced by the pathname of the current file. |
arguments it is replaced by the pathname of the current file. |
.Ar Utility |
.Ar utility |
will be executed from the directory from which |
will be executed from the directory from which |
.Nm find |
.Nm find |
was executed. |
was executed. |
|
|
primary is identical to the |
primary is identical to the |
.Ic -exec |
.Ic -exec |
primary with the exception that |
primary with the exception that |
.Ar Utility |
.Ar utility |
will be executed from the directory that holds |
will be executed from the directory that holds |
the current file. The filename substituted for |
the current file. The filename substituted for |
the string ``{}'' is not qualified. |
the string ``{}'' is not qualified. |
|
|
Two special file system types are recognized: ``local'' and ``rdonly''. |
Two special file system types are recognized: ``local'' and ``rdonly''. |
These do not describe actual file system types; |
These do not describe actual file system types; |
the former matches any file system physically mounted on the system where |
the former matches any file system physically mounted on the system where |
the |
|
.Nm find |
.Nm find |
is being executed, and the latter matches any file system which is |
is being executed, and the latter matches any file system which is |
mounted read-only. |
mounted read-only. |
|
|
.Ar gname |
.Ar gname |
is numeric and there is no such group name, then |
is numeric and there is no such group name, then |
.Ar gname |
.Ar gname |
is treated as a group id. |
is treated as a group ID. |
.It Ic -inum Ar n |
.It Ic -inum Ar n |
True if the file has inode number |
True if the file has inode number |
.Ar n . |
.Ar n . |
|
|
.Ic -exec |
.Ic -exec |
primary with the exception that |
primary with the exception that |
.Nm find |
.Nm find |
requests user affirmation for the execution of the utility by printing |
requests user affirmation for the execution of |
|
.Ar utility |
|
by printing |
a message to the terminal and reading a response. |
a message to the terminal and reading a response. |
If the response is other than ``y'' the command is not executed and the |
If the response is other than ``y'' the command is not executed and the |
value of the |
value of the |
.Ar \&ok |
.Ic \&ok |
expression is false. |
expression is false. |
.It Ic -name Ar pattern |
.It Ic -name Ar pattern |
True if the last component of the pathname being examined matches |
True if the last component of the pathname being examined matches |
|
|
may be used as part of |
may be used as part of |
.Ar pattern . |
.Ar pattern . |
These characters may be matched explicitly by escaping them with a |
These characters may be matched explicitly by escaping them with a |
backslash (``\e''). |
backslash (`\e'). |
.It Ic -newer Ar file |
.It Ic -newer Ar file |
True if the current file has a more recent last modification time than |
True if the current file has a more recent last modification time than |
.Ar file . |
.Ar file . |
|
|
may be used as part of |
may be used as part of |
.Ar pattern . |
.Ar pattern . |
These characters may be matched explicitly by escaping them with a |
These characters may be matched explicitly by escaping them with a |
backslash (``\e''). |
backslash (`\e'). |
Slashes (``/'') are treated as normal characters and do not have to be |
Slashes (`/') are treated as normal characters and do not have to be |
matched explicitly. |
matched explicitly. |
.It Ic -perm Op Fl Ns Ar mode |
.It Ic -perm Op Fl Ns Ar mode |
The |
The |
|
|
.Xr chmod 1 ) |
.Xr chmod 1 ) |
or an octal number. |
or an octal number. |
If the mode is symbolic, a starting value of zero is assumed and the |
If the mode is symbolic, a starting value of zero is assumed and the |
mode sets or clears permissions without regard to the process' file mode |
mode sets or clears permissions without regard to the process's file mode |
creation mask. |
creation mask. |
If the mode is octal, only bits 07777 |
If the mode is octal, only bits 07777 |
.Pf ( Dv S_ISUID |
.Pf ( Dv S_ISUID |
|
|
in the comparison. |
in the comparison. |
If the mode is preceded by a dash (``\-''), this primary evaluates to true |
If the mode is preceded by a dash (``\-''), this primary evaluates to true |
if at least all of the bits in the mode are set in the file's mode bits. |
if at least all of the bits in the mode are set in the file's mode bits. |
If the mode is not preceded by a dash, this primary evaluates to true if |
If the mode is not preceded by a dash (``\-''), this primary evaluates to |
the bits in the mode exactly match the file's mode bits. |
true if the bits in the mode exactly match the file's mode bits. |
Note, the first character of a symbolic mode may not be a dash (``\-''). |
Note, the first character of a symbolic mode may not be a dash (``\-''). |
.It Ic -print |
.It Ic -print |
This primary always evaluates to true. |
This primary always evaluates to true. |
It prints the pathname of the current file to standard output, followed |
It prints the pathname of the current file to standard output, followed |
by a newline character. |
by a newline (``\en'') character. |
If neither |
If neither |
.Ic -exec , |
.Ic -exec , |
.Ic -ls , |
.Ic -ls , |
|
|
.Ar uname |
.Ar uname |
is numeric and there is no such user name, then |
is numeric and there is no such user name, then |
.Ar uname |
.Ar uname |
is treated as a user id. |
is treated as a user ID. |
.El |
.El |
.Pp |
.Pp |
All primaries which take a numeric argument allow the number to be |
All primaries which take a numeric argument allow the number to be |
preceded by a plus sign (``+'') or a minus sign (``\-''). |
preceded by a plus sign (``+'') or a minus sign (``\-''). |
A preceding plus sign means ``more than n'', a preceding minus sign means |
A preceding plus sign means ``more than n'', a preceding minus sign means |
``less than n'' and neither means ``exactly n'' . |
``less than n'', and neither means ``exactly n'' . |
.Sh OPERATORS |
.Sh OPERATORS |
The primaries may be combined using the following operators. |
The primaries may be combined using the following operators. |
The operators are listed in order of decreasing precedence. |
The operators are listed in order of decreasing precedence. |
|
|
to be a separate argument to |
to be a separate argument to |
.Nm find . |
.Nm find . |
.Sh EXAMPLES |
.Sh EXAMPLES |
.Pp |
|
The following examples are shown as given to the shell: |
The following examples are shown as given to the shell: |
.Bl -tag -width findx |
.Bl -tag -width findx |
.It Li "find / \e! -name \*q*.c\*q -print" |
.It Li "find / \e! -name \*q*.c\*q -print" |
|
|
.Xr locate 1 , |
.Xr locate 1 , |
.Xr stat 2 , |
.Xr stat 2 , |
.Xr fts 3 , |
.Xr fts 3 , |
.Xr getpwent 3 , |
|
.Xr getgrent 3 , |
.Xr getgrent 3 , |
|
.Xr getpwent 3 , |
.Xr strmode 3 , |
.Xr strmode 3 , |
.Xr symlink 7 |
.Xr symlink 7 |
.Sh STANDARDS |
.Sh STANDARDS |