[BACK]Return to find.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / find

Annotation of src/usr.bin/find/find.1, Revision 1.89

1.89    ! jmc         1: .\"    $OpenBSD: find.1,v 1.88 2014/03/20 08:49:32 jmc Exp $
1.1       deraadt     2: .\" Copyright (c) 1990, 1993
                      3: .\"    The Regents of the University of California.  All rights reserved.
                      4: .\"
                      5: .\" This code is derived from software contributed to Berkeley by
                      6: .\" the Institute of Electrical and Electronics Engineers, Inc.
                      7: .\"
                      8: .\" Redistribution and use in source and binary forms, with or without
                      9: .\" modification, are permitted provided that the following conditions
                     10: .\" are met:
                     11: .\" 1. Redistributions of source code must retain the above copyright
                     12: .\"    notice, this list of conditions and the following disclaimer.
                     13: .\" 2. Redistributions in binary form must reproduce the above copyright
                     14: .\"    notice, this list of conditions and the following disclaimer in the
                     15: .\"    documentation and/or other materials provided with the distribution.
1.38      millert    16: .\" 3. Neither the name of the University nor the names of its contributors
1.1       deraadt    17: .\"    may be used to endorse or promote products derived from this software
                     18: .\"    without specific prior written permission.
                     19: .\"
                     20: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     21: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     22: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     23: .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     24: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     25: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     26: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     27: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     28: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     29: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     30: .\" SUCH DAMAGE.
                     31: .\"
                     32: .\"    from: @(#)find.1        8.1 (Berkeley) 6/6/93
                     33: .\"
1.89    ! jmc        34: .Dd $Mdocdate: March 20 2014 $
1.1       deraadt    35: .Dt FIND 1
                     36: .Os
                     37: .Sh NAME
                     38: .Nm find
                     39: .Nd walk a file hierarchy
                     40: .Sh SYNOPSIS
                     41: .Nm find
1.48      millert    42: .Op Fl dHhLXx
1.43      jaredy     43: .Op Fl f Ar path
                     44: .Ar path ...\&
1.34      deraadt    45: .Op Ar expression
1.1       deraadt    46: .Sh DESCRIPTION
1.22      aaron      47: .Nm
1.1       deraadt    48: recursively descends the directory tree for each
1.43      jaredy     49: .Ar path
1.1       deraadt    50: listed, evaluating an
                     51: .Ar expression
1.22      aaron      52: (composed of the
                     53: .Dq primaries
                     54: and
1.52      otto       55: .Dq operators
1.22      aaron      56: listed below) in terms
1.12      millert    57: of each file in the tree.
1.34      deraadt    58: In the absence of an expression,
                     59: .Ic -print
                     60: is assumed.
1.66      jmc        61: If an expression is given,
                     62: but none of the primaries
                     63: .Ic -exec ,
                     64: .Ic -ls ,
                     65: .Ic -ok ,
                     66: .Ic -print ,
                     67: or
                     68: .Ic -print0
1.67      jmc        69: are specified, the given expression is effectively replaced by
1.66      jmc        70: .Cm \&( Ar given expression Cm \&)
                     71: .Ic -print .
1.1       deraadt    72: .Pp
                     73: The options are as follows:
                     74: .Bl -tag -width Ds
                     75: .It Fl d
1.16      aaron      76: Causes
1.22      aaron      77: .Nm
1.45      jmc        78: to visit directories in post-order
                     79: i.e. all entries in a directory will be acted on before the directory itself.
1.1       deraadt    80: By default,
1.22      aaron      81: .Nm
1.45      jmc        82: visits directories in pre-order i.e. before their contents.
1.43      jaredy     83: .It Fl f Ar path
1.16      aaron      84: Specifies a file hierarchy for
1.22      aaron      85: .Nm
1.1       deraadt    86: to traverse.
1.52      otto       87: File hierarchies may be specified without the
                     88: .Fl f
                     89: option if they are given immediately after any other options.
1.35      millert    90: .It Fl H
                     91: Causes the file information and file type (see
                     92: .Xr stat 2 )
                     93: returned for each symbolic link encountered on the command line to be
                     94: those of the file referenced by the link, not the link itself.
                     95: If the referenced file does not exist, the file information and type will
                     96: be for the link itself.
                     97: File information of all symbolic links not on
                     98: the command line is that of the link itself.
1.1       deraadt    99: .It Fl h
1.35      millert   100: An alias for the
                    101: .Fl L
                    102: option.
1.37      david     103: This option exists for backwards compatibility.
1.35      millert   104: .It Fl L
1.16      aaron     105: Causes the file information and file type (see
1.22      aaron     106: .Xr stat 2 )
1.1       deraadt   107: returned for each symbolic link to be those of the file referenced by the
                    108: link, not the link itself.
                    109: If the referenced file does not exist, the file information and type will
                    110: be for the link itself.
                    111: .It Fl X
1.16      aaron     112: Permit
1.1       deraadt   113: .Nm
                    114: to be safely used in conjunction with
                    115: .Xr xargs 1 .
1.87      schwarze  116: If a file name contains any of the delimiting characters used by xargs,
1.1       deraadt   117: a diagnostic message is displayed on standard error, and the file
                    118: is skipped.
1.22      aaron     119: The delimiting characters include single
                    120: .Pq Ql '
                    121: and double
                    122: .Pq Ql \&"
                    123: quotes, backslash
                    124: .Pq Ql \e ,
                    125: space, tab, and newline
                    126: .Pq Sq \en
                    127: characters.
1.79      schwarze  128: Consider using
1.4       deraadt   129: .Fl print0
1.79      schwarze  130: instead.
1.1       deraadt   131: .It Fl x
1.16      aaron     132: Prevents
1.22      aaron     133: .Nm
1.1       deraadt   134: from descending into directories that have a device number different
                    135: than that of the file from which the descent began.
                    136: .El
1.76      schwarze  137: .Pp
                    138: It is not an error to specify more than one of
                    139: the mutually exclusive options
                    140: .Fl H
                    141: and
                    142: .Fl L .
                    143: Where more than one of these options is specified,
                    144: the last option given overrides the others.
1.1       deraadt   145: .Sh PRIMARIES
1.84      jmc       146: .Bl -tag -width Ds -compact
1.22      aaron     147: .It Ic -amin Ar n
1.15      deraadt   148: True if the difference between the file last access time and the time
1.22      aaron     149: .Nm
1.20      aaron     150: was started, rounded up to the next full minute, is
1.15      deraadt   151: .Ar n
1.20      aaron     152: minutes.
1.84      jmc       153: .Pp
1.24      millert   154: .It Ic -anewer Ar file
                    155: True if the current file has a more recent last access time than
1.25      aaron     156: .Ar file .
1.84      jmc       157: .Pp
1.22      aaron     158: .It Ic -atime Ar n
1.1       deraadt   159: True if the difference between the file last access time and the time
1.22      aaron     160: .Nm
                    161: was started, rounded up to the next full 24-hour period, is
1.1       deraadt   162: .Ar n
1.22      aaron     163: 24-hour periods.
1.84      jmc       164: .Pp
1.22      aaron     165: .It Ic -cmin Ar n
1.15      deraadt   166: True if the difference between the time of last change of file status
                    167: information and the time
1.22      aaron     168: .Nm
1.20      aaron     169: was started, rounded up to the next full minute, is
1.15      deraadt   170: .Ar n
1.20      aaron     171: minutes.
1.84      jmc       172: .Pp
1.24      millert   173: .It Ic -cnewer Ar file
                    174: True if the current file has a more recent last change time than
1.25      aaron     175: .Ar file .
1.84      jmc       176: .Pp
1.22      aaron     177: .It Ic -ctime Ar n
1.1       deraadt   178: True if the difference between the time of last change of file status
                    179: information and the time
1.22      aaron     180: .Nm
                    181: was started, rounded up to the next full 24-hour period, is
1.1       deraadt   182: .Ar n
1.22      aaron     183: 24-hour periods.
1.84      jmc       184: .Pp
1.56      jmc       185: .It Ic -depth
1.61      jmc       186: This primary always evaluates to true.
1.56      jmc       187: The same as specifying the
                    188: .Fl d
                    189: option.
1.84      jmc       190: .Pp
1.8       tholo     191: .It Ic -empty
                    192: True if the current file or directory is empty.
1.84      jmc       193: .Pp
1.89    ! jmc       194: .It Ic -exec Ar utility Oo Ar argument ... Oc \&;
        !           195: .It Ic -exec Ar utility Oo Ar argument ... Oc {} +
1.83      pascal    196: Execute the specified
                    197: .Ar utility .
1.1       deraadt   198: Optional arguments may be passed to the utility.
1.22      aaron     199: The expression must be terminated by a semicolon
1.83      pascal    200: .Pq Ql \&;
                    201: or a plus sign
                    202: .Pq Ql \&+ .
                    203: .Pp
                    204: If terminated by a semicolon, the
                    205: .Ar utility
                    206: is executed once per path.
1.22      aaron     207: If the string
                    208: .Qq {}
                    209: appears anywhere in the utility name or the
1.1       deraadt   210: arguments it is replaced by the pathname of the current file.
1.83      pascal    211: .Pp
1.84      jmc       212: If terminated by a plus sign,
1.83      pascal    213: the pathnames for which the
                    214: primary is evaluated are aggregated into sets, and
1.16      aaron     215: .Ar utility
1.83      pascal    216: will be invoked once per set, similar to
                    217: .Xr xargs 1 .
1.84      jmc       218: If any invocation exits with a non-zero exit status, then
1.83      pascal    219: .Nm
                    220: will eventually do so as well, but this does not cause
1.22      aaron     221: .Nm
1.83      pascal    222: to exit early.
                    223: The string
1.84      jmc       224: .Qq {}
1.83      pascal    225: must appear, and must appear last.
                    226: Each set is limited to no more than 5,000 pathnames,
                    227: and is also limited such that the invocation of
1.63      otto      228: .Ar utility
1.83      pascal    229: does not exceed
                    230: .Dv ARG_MAX .
1.84      jmc       231: .Pp
1.89    ! jmc       232: .It Ic -execdir Ar utility Oo Ar argument ... Oc \&;
1.85      sthen     233: Identical to the first form of the
1.10      millert   234: .Ic -exec
                    235: primary with the exception that
1.16      aaron     236: .Ar utility
1.10      millert   237: will be executed from the directory that holds
1.25      aaron     238: the current file.
                    239: The filename substituted for the string
1.22      aaron     240: .Qq {}
                    241: is not qualified.
1.84      jmc       242: .Pp
1.28      millert   243: .It Xo
                    244: .Ic -flags
1.65      jmc       245: .Oo - Oc Ns Ar flags
1.28      millert   246: .Xc
                    247: The
                    248: .Ar flags
                    249: are comma-separated symbolic file flags (see
                    250: .Xr chflags 1
                    251: for a list of valid flag names).
                    252: If the flags are preceded by a dash
1.54      jmc       253: .Pq Sq - ,
1.49      otto      254: this primary evaluates to true if at least all specified
                    255: .Ar flags
                    256: are set in the file's flags.
1.28      millert   257: If the flags are not preceded by a dash, this primary evaluates to true if the
                    258: flags specified exactly match those of the file.
1.84      jmc       259: .Pp
1.2       deraadt   260: .It Ic -follow
1.61      jmc       261: This primary always evaluates to true.
1.56      jmc       262: The same as specifying the
1.86      halex     263: .Fl L
1.56      jmc       264: option.
1.84      jmc       265: .Pp
1.22      aaron     266: .It Ic -fstype Ar type
1.1       deraadt   267: True if the file is contained in a file system of type
                    268: .Ar type .
1.22      aaron     269: Two special file system types are recognized:
                    270: .Dq local
                    271: and
                    272: .Dq rdonly .
1.1       deraadt   273: These do not describe actual file system types;
                    274: the former matches any file system physically mounted on the system where
1.22      aaron     275: .Nm
                    276: is being executed whereas the latter matches any file system which is
1.1       deraadt   277: mounted read-only.
1.84      jmc       278: .Pp
1.22      aaron     279: .It Ic -group Ar gname
1.1       deraadt   280: True if the file belongs to the group
1.25      aaron     281: .Ar gname .
1.1       deraadt   282: If
                    283: .Ar gname
                    284: is numeric and there is no such group name, then
                    285: .Ar gname
1.16      aaron     286: is treated as a group ID.
1.84      jmc       287: .Pp
1.27      deraadt   288: .It Ic -iname Ar pattern
1.77      schwarze  289: Identical to the
                    290: .Ic -name
                    291: primary except that the matching is done in a case insensitive manner.
1.84      jmc       292: .Pp
1.22      aaron     293: .It Ic -inum Ar n
1.1       deraadt   294: True if the file has inode number
1.25      aaron     295: .Ar n .
1.84      jmc       296: .Pp
1.22      aaron     297: .It Ic -links Ar n
1.1       deraadt   298: True if the file has
                    299: .Ar n
                    300: links.
1.84      jmc       301: .Pp
1.1       deraadt   302: .It Ic -ls
                    303: This primary always evaluates to true.
                    304: The following information for the current file is written to standard output:
1.22      aaron     305: its inode number, size in 512-byte blocks, file permissions, number of hard
1.1       deraadt   306: links, owner, group, size in bytes, last modification time, and pathname.
                    307: If the file is a block or character special file, the major and minor numbers
                    308: will be displayed instead of the size in bytes.
1.22      aaron     309: If the file is a symbolic link, the pathname of the linked-to file will be
                    310: displayed preceded by
1.89    ! jmc       311: .Dq -> .
1.22      aaron     312: The format is identical to that produced by
1.71      jmc       313: .Dq ls -dils .
1.84      jmc       314: .Pp
1.6       tholo     315: .It Ic -maxdepth Ar n
1.7       tholo     316: True if the current search depth is less than or equal to what is specified in
                    317: .Ar n .
1.84      jmc       318: .Pp
1.7       tholo     319: .It Ic -mindepth Ar n
                    320: True if the current search depth is at least what is specified in
1.6       tholo     321: .Ar n .
1.84      jmc       322: .Pp
1.22      aaron     323: .It Ic -mmin Ar n
1.15      deraadt   324: True if the difference between the file last modification time and the time
1.22      aaron     325: .Nm
1.20      aaron     326: was started, rounded up to the next full minute, is
1.15      deraadt   327: .Ar n
1.20      aaron     328: minutes.
1.84      jmc       329: .Pp
1.22      aaron     330: .It Ic -mtime Ar n
1.1       deraadt   331: True if the difference between the file last modification time and the time
1.22      aaron     332: .Nm
                    333: was started, rounded up to the next full 24-hour period, is
1.1       deraadt   334: .Ar n
1.22      aaron     335: 24-hour periods.
1.84      jmc       336: .Pp
1.22      aaron     337: .It Ic -name Ar pattern
1.1       deraadt   338: True if the last component of the pathname being examined matches
1.77      schwarze  339: .Ar pattern ,
                    340: which may use any of the special characters documented in
                    341: .Xr glob 7 .
1.84      jmc       342: .Pp
1.22      aaron     343: .It Ic -newer Ar file
1.1       deraadt   344: True if the current file has a more recent last modification time than
1.25      aaron     345: .Ar file .
1.84      jmc       346: .Pp
1.44      jmc       347: .It Ic -nogroup
                    348: True if the file belongs to an unknown group.
1.84      jmc       349: .Pp
1.1       deraadt   350: .It Ic -nouser
                    351: True if the file belongs to an unknown user.
1.84      jmc       352: .Pp
1.89    ! jmc       353: .It Ic -ok Ar utility Oo Ar argument ... Oc \&;
1.22      aaron     354: Identical to the
                    355: .Ic -exec
                    356: primary with the exception that
                    357: .Nm
                    358: requests user affirmation for the execution of
                    359: .Ar utility
                    360: by printing
                    361: a message to the terminal and reading a response.
                    362: If the response is other than
                    363: .Sq y
                    364: the command is not executed and the
                    365: value of the
1.54      jmc       366: .Ic ok
1.22      aaron     367: expression is false.
1.84      jmc       368: .Pp
1.22      aaron     369: .It Ic -path Ar pattern
1.1       deraadt   370: True if the pathname being examined matches
1.77      schwarze  371: .Ar pattern ,
                    372: which may use any of the special characters documented in
                    373: .Xr glob 7 .
1.22      aaron     374: Slashes
                    375: .Pq Ql /
                    376: are treated as normal characters and do not have to be
1.1       deraadt   377: matched explicitly.
1.84      jmc       378: .Pp
1.21      aaron     379: .It Xo
                    380: .Ic -perm
1.65      jmc       381: .Oo - Oc Ns Ar mode
1.21      aaron     382: .Xc
1.1       deraadt   383: The
                    384: .Ar mode
                    385: may be either symbolic (see
1.25      aaron     386: .Xr chmod 1 )
1.1       deraadt   387: or an octal number.
                    388: If the mode is symbolic, a starting value of zero is assumed and the
1.16      aaron     389: mode sets or clears permissions without regard to the process's file mode
1.1       deraadt   390: creation mask.
                    391: If the mode is octal, only bits 07777
1.64      jmc       392: .Po
1.70      kili      393: .Dv S_ISUID \*(Ba S_ISGID \*(Ba S_ISTXT \*(Ba
1.64      jmc       394: .Dv S_IRWXU \*(Ba S_IRWXG \*(Ba S_IRWXO
                    395: .Pc
1.1       deraadt   396: of the file's mode bits participate
                    397: in the comparison.
1.22      aaron     398: If the mode is preceded by a dash
1.54      jmc       399: .Pq Sq - ,
1.22      aaron     400: this primary evaluates to true
1.1       deraadt   401: if at least all of the bits in the mode are set in the file's mode bits.
1.22      aaron     402: If the mode is not preceded by a dash, this primary evaluates to
1.16      aaron     403: true if the bits in the mode exactly match the file's mode bits.
1.22      aaron     404: Note, the first character of a symbolic mode may not be a dash.
1.84      jmc       405: .Pp
1.1       deraadt   406: .It Ic -print
                    407: This primary always evaluates to true.
                    408: It prints the pathname of the current file to standard output, followed
1.22      aaron     409: by a newline
                    410: .Pq Ql \en
                    411: character.
1.84      jmc       412: .Pp
1.1       deraadt   413: .It Ic -print0
                    414: This primary always evaluates to true.
                    415: It prints the pathname of the current file to standard output, followed
1.79      schwarze  416: by a null character, suitable for use with the
                    417: .Fl 0
                    418: option to
                    419: .Xr xargs 1 .
1.84      jmc       420: .Pp
1.1       deraadt   421: .It Ic -prune
                    422: This primary always evaluates to true.
                    423: It causes
1.22      aaron     424: .Nm
1.1       deraadt   425: to not descend into the current file.
                    426: Note, the
                    427: .Ic -prune
                    428: primary has no effect if the
                    429: .Fl d
                    430: option was specified.
1.84      jmc       431: .Pp
1.22      aaron     432: .It Ic -size Ar n Ns Op Cm c
                    433: True if the file's size, rounded up, in 512-byte blocks is
1.25      aaron     434: .Ar n .
1.1       deraadt   435: If
                    436: .Ar n
1.22      aaron     437: is followed by a
                    438: .Sq c ,
                    439: then the primary is true if the
1.1       deraadt   440: file's size is
                    441: .Ar n
                    442: bytes.
1.84      jmc       443: .Pp
1.22      aaron     444: .It Ic -type Ar t
1.1       deraadt   445: True if the file is of the specified type.
                    446: Possible file types are as follows:
                    447: .Pp
                    448: .Bl -tag -width flag -offset indent -compact
                    449: .It Cm b
                    450: block special
                    451: .It Cm c
                    452: character special
                    453: .It Cm d
                    454: directory
                    455: .It Cm f
                    456: regular file
                    457: .It Cm l
                    458: symbolic link
                    459: .It Cm p
                    460: FIFO
                    461: .It Cm s
                    462: socket
                    463: .El
                    464: .Pp
1.22      aaron     465: .It Ic -user Ar uname
1.1       deraadt   466: True if the file belongs to the user
1.25      aaron     467: .Ar uname .
1.1       deraadt   468: If
                    469: .Ar uname
                    470: is numeric and there is no such user name, then
                    471: .Ar uname
1.16      aaron     472: is treated as a user ID.
1.84      jmc       473: .Pp
1.56      jmc       474: .It Ic -xdev
1.61      jmc       475: This primary always evaluates to true.
1.56      jmc       476: The same as specifying the
                    477: .Fl x
                    478: option.
1.1       deraadt   479: .El
                    480: .Pp
                    481: All primaries which take a numeric argument allow the number to be
1.22      aaron     482: preceded by a plus sign
                    483: .Pq Ql +
                    484: or a minus sign
1.54      jmc       485: .Pq Ql - .
1.22      aaron     486: A preceding plus sign means
                    487: .Dq more than n ,
                    488: a preceding minus sign means
                    489: .Dq less than n ,
                    490: and neither means
                    491: .Dq exactly n .
1.74      jmc       492: Exceptions are the primaries
                    493: .Ic mindepth
                    494: and
                    495: .Ic maxdepth .
1.1       deraadt   496: .Sh OPERATORS
                    497: The primaries may be combined using the following operators.
                    498: The operators are listed in order of decreasing precedence.
1.47      jmc       499: .Pp
                    500: .Bl -tag -width "(expression)" -compact
1.51      jmc       501: .It Cm \&( Ar expression Cm \&)
1.1       deraadt   502: This evaluates to true if the parenthesized expression evaluates to
                    503: true.
                    504: .Pp
1.51      jmc       505: .It Cm \&! Ar expression
1.1       deraadt   506: This is the unary
                    507: .Tn NOT
                    508: operator.
                    509: It evaluates to true if the expression is false.
                    510: .Pp
1.89    ! jmc       511: .It Ar expression Cm -a Ar expression
1.22      aaron     512: .It Ar expression Cm -and Ar expression
                    513: .It Ar expression expression
1.89    ! jmc       514: The logical AND operator.
1.1       deraadt   515: As it is implied by the juxtaposition of two expressions it does not
                    516: have to be specified.
                    517: The expression evaluates to true if both expressions are true.
                    518: The second expression is not evaluated if the first expression is false.
                    519: .Pp
1.89    ! jmc       520: .It Ar expression Cm -o Ar expression
1.22      aaron     521: .It Ar expression Cm -or Ar expression
1.89    ! jmc       522: The logical OR operator.
1.1       deraadt   523: The expression evaluates to true if either the first or the second expression
                    524: is true.
                    525: The second expression is not evaluated if the first expression is true.
                    526: .El
                    527: .Pp
1.53      otto      528: Operators, primaries, and arguments to primaries must be separate
                    529: arguments to
                    530: .Nm find ,
                    531: i.e. they should be separated by whitespace.
1.81      jmc       532: .Sh EXIT STATUS
                    533: The
                    534: .Nm
                    535: utility exits with a value of 0 on successful traversal of all path operands
1.89    ! jmc       536: or with a value >0 if an error occurred.
1.1       deraadt   537: .Sh EXAMPLES
1.62      jmc       538: Print out a list of all the files whose names end in
1.43      jaredy    539: .Dq \&.c :
                    540: .Pp
1.62      jmc       541: .Dl "$ find / -name '*.c'"
1.43      jaredy    542: .Pp
1.22      aaron     543: Print out a list of all the files which are not both newer than
                    544: .Dq ttt
                    545: and owned by
1.43      jaredy    546: .Dq wnj :
                    547: .Pp
1.62      jmc       548: .Dl "$ find / \e! \e( -newer ttt -user wnj \e)"
1.43      jaredy    549: .Pp
                    550: Print out a list of all core files on local file systems:
                    551: .Pp
1.88      jmc       552: .Dl "$ find / \e! -fstype local -prune -o -name '*.core'"
1.46      jmc       553: .Pp
                    554: Find all files in
                    555: .Pa /usr/src
                    556: ending in a dot and single digit, but skip directory
                    557: .Pa /usr/src/gnu :
                    558: .Pp
1.88      jmc       559: .Dl "$ find /usr/src -path /usr/src/gnu -prune -o -name \e*.[0-9]"
1.62      jmc       560: .Pp
1.79      schwarze  561: Find and remove all *.jpg and *.gif files under the current working
                    562: directory:
1.62      jmc       563: .Pp
1.88      jmc       564: .Dl "$ find . \e( -name \e*.jpg -o -name \e*.gif \e) -exec rm {} \e;"
1.63      otto      565: or
1.88      jmc       566: .Dl "$ find . \e( -name \e*.jpg -o -name \e*.gif \e) -print0 | xargs -0r rm"
1.1       deraadt   567: .Sh SEE ALSO
1.29      millert   568: .Xr chflags 1 ,
1.1       deraadt   569: .Xr chmod 1 ,
                    570: .Xr locate 1 ,
1.77      schwarze  571: .Xr ls 1 ,
1.23      aaron     572: .Xr whereis 1 ,
                    573: .Xr which 1 ,
1.41      millert   574: .Xr xargs 1 ,
1.1       deraadt   575: .Xr stat 2 ,
                    576: .Xr fts 3 ,
1.77      schwarze  577: .Xr glob 7 ,
1.1       deraadt   578: .Xr symlink 7
                    579: .Sh STANDARDS
                    580: The
1.22      aaron     581: .Nm
1.68      jmc       582: utility is compliant with the
1.72      jmc       583: .St -p1003.1-2008
1.68      jmc       584: specification.
1.1       deraadt   585: .Pp
1.55      jmc       586: The options
1.88      jmc       587: .Op Fl dfhXx ,
                    588: primaries
1.18      deraadt   589: .Ic -amin ,
1.55      jmc       590: .Ic -anewer ,
1.18      deraadt   591: .Ic -cmin ,
1.55      jmc       592: .Ic -cnewer ,
1.9       tholo     593: .Ic -empty ,
1.55      jmc       594: .Ic -execdir ,
                    595: .Ic -flags ,
1.1       deraadt   596: .Ic -follow ,
                    597: .Ic -fstype ,
1.27      deraadt   598: .Ic -iname ,
1.2       deraadt   599: .Ic -inum ,
1.9       tholo     600: .Ic -ls ,
                    601: .Ic -maxdepth ,
1.13      deraadt   602: .Ic -mindepth ,
1.55      jmc       603: .Ic -mmin ,
1.1       deraadt   604: and
1.88      jmc       605: .Ic -print0 ,
                    606: and operators
                    607: .Fl or
                    608: and
                    609: .Fl and ,
1.68      jmc       610: are extensions to that specification.
1.1       deraadt   611: .Pp
                    612: Historically, the
                    613: .Fl d ,
1.86      halex     614: .Fl L ,
1.1       deraadt   615: and
                    616: .Fl x
1.14      deraadt   617: options were implemented using the primaries
                    618: .Ic -depth ,
                    619: .Ic -follow ,
                    620: and
                    621: .Ic -xdev .
1.1       deraadt   622: These primaries always evaluated to true.
                    623: As they were really global variables that took effect before the traversal
                    624: began, some legal expressions could have unexpected results.
1.22      aaron     625: An example is the expression
1.54      jmc       626: .Dq -print -o -depth .
1.22      aaron     627: As
1.54      jmc       628: .Cm -print
1.22      aaron     629: always evaluates to true, the standard order of evaluation
                    630: implies that
1.54      jmc       631: .Cm -depth
1.22      aaron     632: would never be evaluated.
1.1       deraadt   633: This is not the case.
                    634: .Pp
                    635: Historic implementations of the
                    636: .Ic -exec
                    637: and
                    638: .Ic -ok
1.22      aaron     639: primaries did not replace the string
                    640: .Qq {}
                    641: in the utility name or the
1.1       deraadt   642: utility arguments if it had preceding or following non-whitespace characters.
                    643: This version replaces it no matter where in the utility name or arguments
                    644: it appears.
1.30      aaron     645: .Sh HISTORY
                    646: A
                    647: .Nm
                    648: command appeared in
                    649: .At v1 .
1.50      jmc       650: .Sh CAVEATS
1.1       deraadt   651: The special characters used by
1.22      aaron     652: .Nm
1.1       deraadt   653: are also special characters to many shell programs.
1.22      aaron     654: In particular, the characters
                    655: .Ql * ,
1.78      schwarze  656: .Ql \&[ ,
1.22      aaron     657: .Ql \&] ,
1.40      jmc       658: .Ql \&? ,
1.78      schwarze  659: .Ql \&( ,
1.22      aaron     660: .Ql \&) ,
1.40      jmc       661: .Ql \&! ,
1.22      aaron     662: .Ql \e ,
                    663: and
                    664: .Ql \&;
                    665: may have to be escaped from the shell.
1.79      schwarze  666: .Pp
1.82      schwarze  667: As file names may contain whitespace and shell metacharacters,
                    668: passing the output of
1.79      schwarze  669: .Nm
                    670: to other programs requires some care:
                    671: .Pp
                    672: .Dl "$ find . -name \e*.jpg | xargs rm"
                    673: or
                    674: .Dl "$ rm `find . -name \e*.jpg`"
                    675: .Pp
                    676: would, given files
                    677: .Dq important\ .jpg
                    678: and
                    679: .Dq important ,
                    680: remove
                    681: .Dq important .
                    682: Use the
                    683: .Ic -print0
                    684: or
                    685: .Ic -exec
                    686: primaries instead.
1.1       deraadt   687: .Pp
                    688: As there is no delimiter separating options and file names or file
                    689: names and the
                    690: .Ar expression ,
1.22      aaron     691: it is difficult to specify files named
                    692: .Dq -xdev
                    693: or
1.65      jmc       694: .Sq \&! .
1.1       deraadt   695: These problems are handled by the
                    696: .Fl f
                    697: option and the
                    698: .Xr getopt 3
1.65      jmc       699: .Sq --
1.22      aaron     700: construct.