| FIND(1) | General Commands Manual | FIND(1) | 
find —
| find | [ -H|-L|-P] [-dEhsXx]
      file [file ...]
      [expression] | 
| find | [ -H|-L|-P] [-dEhsXx]-ffile
      [file ...] [expression] | 
find recursively descends the directory tree for each
  file listed, evaluating an
  expression (composed of the “primaries”
  and “operands” listed below) in terms of each file in the tree.
The options are as follows:
-H-L-P-dfind to perform a depth-first traversal,
      i.e., directories are visited in post-order, and all entries in a
      directory will be acted on before the directory itself. By default,
      find visits directories in pre-order, i.e., before
      their contents. Note, the default is not a breadth-first
      traversal.-E-ffind to traverse.
      File hierarchies may also be specified as the operands immediately
      following the options.-h-sa/b’ appears before
      ‘a.b’, which is different from
      “find ... | sort” order.-Xfind to be safely
      used in conjunction with
      xargs(1). If a file name
      contains any of the delimiting characters used by
      xargs(1), a diagnostic
      message is displayed on standard error, and the file is skipped. The
      delimiting characters include single (“'”) and double
      (“"”) quotes, backslash (“\”), space,
      tab, and newline characters. Alternatively, the
      -print0 or -printx
      primaries can be used to format the output in a way that
      xargs(1) can accept.-x-user and -group primaries are
  similarly treated if the value is numeric and does not correspond to a valid
  user or group name.)
For primaries which take a timestamp argument, the argument must be valid input to parsedate(3). If the argument contains multiple words, enclose the argument in quotes.
-amin
    nfind was started, rounded up to the next full
      minute, is n minutes.
    
  -anewer
    file-asince
    timestamp-atime
    nfind was started, rounded up to the next full
      24-hour period, is n 24-hour periods.
    
  -cmin
    nfind was started, rounded
      up to the next full minute, is n minutes.
    
  -cnewer
    file-csince
    timestamp-ctime
    nfind was started, rounded
      up to the next full 24-hour period, is n 24-hour
      periods.
    
  -deletefind recurses down the tree. To avoid deleting
      unexpected files, it will ignore any filenames that
      fts(3) returns that contain a
      “/” (fts(3)
      should not return such pathnames). Depth-first traversal processing is
      implied by this option. This primary can also be invoked as
      -rm.
    
  -empty-exec
    utility [argument ...] ;-exec
    utility [argument ...] {}
    +The list of arguments for utility is
        terminated by a lone semicolon “;”
        or plus “+” character as a
        separate parameter. The command specified by
        utility will be executed with its current working
        directory being the directory from which find
        was executed.
If the list of arguments is terminated by a semicolon
        (“;”), then
        utility is invoked once per pathname. If the
        string “{}” appears one or more
        times in the utility name or arguments, then it is replaced by the
        pathname of the current file (but it need not appear, in which case the
        pathname will not be passed to utility). The
        semicolon-terminated form of the -exec primary
        returns true if and only if utility exits with a
        zero exit status. Note that the semicolon will have to be escaped on the
        shell command line in order to be passed as a parameter.
If the list of arguments is terminated by a plus sign
        (“+”), then the pathnames for
        which the primary is evaluated are aggregated into sets, and
        utility will be invoked once per set, similar to
        xargs(1). In this case the
        string “{}” must appear, and must
        appear as the last item in the argument list, just before the
        “+” parameter, and is replaced by
        the pathnames of the current set of files. Each set is limited to no
        more than 5,000 pathnames, and is also limited such that the total
        number of bytes in the argument list does not exceed
        ARG_MAX. The plus-terminated form of the
        -exec primary always returns true. If the
        plus-terminated form of the -exec primary
        results in any invocation of utility exiting with
        non-zero exit status, then find will eventually
        exit with non-zero status as well, but this does not cause
        find to exit early.
-execdir
    utility [argument ...] ;-execdir primary is similar to the
      semicolon-terminated (“;”) variant
      of the -exec primary, with the exception that
      utility will be executed from the directory that
      holds the current file. Only the base filename is substituted for the
      string “{}”. Set aggregation
      (“+” termination) is not supported.
    
  -exit
    [status]find to stop traversing the
      file system and exit immediately, with the specified numeric exit status.
      If the status value is not specified, then
      find will exit with status zero. Note that any
      preceding primaries will be evaluated and acted upon before exiting.
    
  -false-fprint
      primary so it can continue to the next expression (using an
      -or operator, for example).
    
  -flags
    [-]flags-”), this primary evaluates to
      true if at least all of the bits in flags are set in
      the file's flags bits. If flags are not preceded by
      a dash, this primary evaluates to true if the bits in
      flags exactly match the file's flags bits. If
      flags is “none”, files with no flags
      bits set are matched. (See
      chflags(1) for more
      information about file flags.)
    
  -follow-fprint
    filename-fstype
    type
sysctl vfs.generic.fstypes
    
    In addition, there are two pseudo-types, “local”
        and “rdonly”. The former matches any file system
        physically mounted on the system where the find
        is being executed, and the latter matches any file system which is
        mounted read-only.
-group
    gname-iname
    pattern-inum
    n-iregex
    regexp-links
    n-rm-delete.
    
  -ls-maxdepth
    depth-mindepth
    depth-mmin
    nfind was started, rounded up to the next full
      minute, is n minutes.
    
  -mtime
    nfind was started, rounded up to the next full
      24-hour period, is n 24-hour periods.
    
  -ok
    utility [argument ...] ;-ok primary is similar to the
      semicolon-terminated (“;”) variant of the
      -exec primary, with the exception that
      find requests user affirmation for the execution
      of utility by printing a message to the terminal and
      reading a response. If the response is other than “y”, the
      command is not executed and the -ok primary
      evaluates to false. Set aggregation (“+” termination) is not
      supported.
    
  -name
    pattern-newer
    file-newerXY
    reference| findutils | find | 
| option | equivalent | 
| -neweraa | -anewer | 
| -newerat | -asince | 
| -newercc | -cnewer | 
| -newerct | -csince | 
| -newermm | -newer | 
| -newermt | -since | 
Other option variants from findutils are not implemented.
-nouser-nogroup-path
    pattern-perm
    [-]modeS_ISUID |
      S_ISGID
      |
      S_ISTXT
      |
      S_IRWXU
      |
      S_IRWXG
      |
      S_IRWXO)
      of the file's mode bits participate in the comparison. 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 the mode is not preceded by a dash, this
      primary evaluates to 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
      (“-”).
    
  -print-delete, -exec,
      -execdir, -exit,
      -fprint, -ls,
      -ok, -print0,
      -printx, nor -rm is
      specified, the given expression shall be effectively replaced by
      (given
      expression) -print.
    
  -print0-printxfind can safely be
      used as input to xargs(1).
    
  -prunefind to not descend into the current file. Note,
      the -prune primary has no effect if the
      -d option was specified.
    
  -regex
    regexp-since
    timestamp-size
    n[c]c”, then the primary is true if the
      file's size is n bytes.
    
  -type
    t-user
    username-xdev(
    expression )!
    expression-and
    expression-and operator is the logical AND operator. As
      it is implied by the juxtaposition of two expressions it does not have to
      be specified. The expression evaluates to true if both expressions are
      true. The second expression is not evaluated if the first expression is
      false.-or
    expression-or operator is the logical OR operator. The
      expression evaluates to true if either the first or the second expression
      is true. The second expression is not evaluated if the first expression is
      true.All operands and primaries must be separate arguments to
    find. Primaries which themselves take arguments
    expect each argument to be a separate argument to
    find.
find utility normally exits 0 on success, and exits
  with 1 under certain internal error conditions. If any invocations of
  “-exec ...
  +” primaries return non-zero exit-status, then
  find will do so as well.
find
    / \! -name "*.c" -printfind
    / -newer ttt -user wnj -printfind
    . -type f -mmin -30 -print -or -mindepth 1 -prunefind
    . -type f -atime +10 -mindepth 2 -printfind
    . -mtime +90 -exec rm -i {} + -or -mindepth 1 -prunefind
    . -type f -mtime +90 -ok mv {} {}.old \;find
    / \! \( -newer ttt -user wnj \) -printfind
    / \( -newer ttt -or -user wnj \) -printfind
    / \( -newer ttt -or -user wnj \) -exit 1find
    / \( -newer ttt -or -user wnj \) -ls -exit 1find
    . -type f -exec sh -c 'file="$1"; ...;' - {} ;find utility syntax is a superset of the syntax
  specified by the IEEE Std 1003.2
  (“POSIX.2”) standard.
The options and the -amin,
    -anewer, -asince,
    -cmin, -cnewer,
    -csince, -delete,
    -empty, -execdir,
    -follow, -fstype,
    -iname, -inum,
    -iregex, -links,
    -ls, -maxdepth,
    -mindepth, -mmin,
    -path, -print0,
    -printx, -regex,
    -rm, and -since primaries
    are extensions to IEEE Std 1003.2
    (“POSIX.2”).
Historically, the -d,
    -h, and -x options were
    implemented using the primaries
    “-depth”,
    “-follow”, and
    “-xdev”. These primaries always
    evaluated to true, and always took effect when the
    expression was parsed, before the file system
    traversal began. As a result, some legal expressions could be confusing. For
    example, in the expression “-print
    -or -depth”,
    -print always evaluates to true, so the standard
    meaning of -or implies that
    -depth would never be evaluated, but that is not
    what happens; in fact, -depth takes effect
    immediately, without testing whether -print returns
    true or false.
Historically, the operator
    “-or” was implemented as
    “-o”, and the operator
    “-and” was implemented as
    “-a”.
Historic implementations of the
    “-exec” and
    “-ok” primaries did not replace the
    string “{}” in the utility name or the
    utility arguments if it did not appear as a separate argument. This version
    replaces it no matter where in the utility name or arguments it appears.
Support for “-exec
    ... +” is consistent
    with IEEE PASC Interpretation 1003.2 #210, though the
    feature originated in SVR4.
The -delete primary does not interact well
    with other options that cause the file system tree traversal options to be
    changed.
find command appeared in First Edition
  AT&T Unix. The syntax had become similar to the present version by the
  time of the Fifth Edition.
find are also special
  characters to many shell programs. In particular, the characters
  “*”, “[”, “]”, “?”,
  “(”, “)”, “!”, “\”,
  and “;” may have to be escaped from the shell.
As there is no delimiter separating options and file names or file
    names and the expression, it is difficult to specify
    files named “-xdev” or “!”. These problems are
    handled by the -f option and the
    getopt(3) “--”
    construct.
| June 13, 2016 | NetBSD 9.4 |