FIND(1)                     NetBSD Reference Manual                    FIND(1)

NNAAMMEE
     ffiinndd - walk a file hierarchy

SSYYNNOOPPSSIISS
     ffiinndd [--HHddhhXXxx] [--ff _f_i_l_e] [_f_i_l_e _._._.] _e_x_p_r_e_s_s_i_o_n

DDEESSCCRRIIPPTTIIOONN
     FFiinndd recursively descends the directory tree for each _f_i_l_e listed, evalu-
     ating an _e_x_p_r_e_s_s_i_o_n (composed of the ``primaries'' and ``operands'' list-
     ed below) in terms of each file in the tree.

     The options are as follows:

     --HH      The --HH option causes the file information and file type (see
             stat(2)),  returned for each symbolic link encountered on the
             command line to be 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 be for the link itself.  File informa-
             tion of all symbolic links not on the command line is that of the
             link itself.

     --dd      The --dd option causes ffiinndd 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 de-
             fault, ffiinndd visits directories in pre-order, i.e. before their
             contents.  Note, the default is _n_o_t a breadth-first traversal.

     --ff      The --ff option specifies a file hierarchy for ffiinndd to traverse.
             File hierarchies may also be specified as the operands immediate-
             ly following the options.

     --hh      The --hh option causes the file information and file type (see
             stat(2)),  returned for each symbolic link to be those of the
             file referenced by the link, not the link itself.  If the refer-
             enced file does not exist, the file information and type will be
             for the link itself.

     --XX      The --XX option is a modification to permit ffiinndd to be safely used
             in conjunction with xargs(1).  If a file name contains any of the
             delimiting characters used by xargs,  a diagnostic message is
             displayed on standard error, and the file is skipped.  The delim-
             iting characters include single (`` ' '') and double (`` " '')
             quotes, backslash (``\''), space, tab and newline characters.

     --xx      The --xx option prevents ffiinndd from descending into directories that
             have a device number different than that of the file from which
             the descent began.

PPRRIIMMAARRIIEESS
     --aattiimmee _n
             True if the difference between the file last access time and the
             time ffiinndd was started, rounded up to the next full 24-hour peri-
             od, is _n 24-hour periods.

     --ccttiimmee _n
             True if the difference between the time of last change of file
             status information and the time ffiinndd was started, rounded up to
             the next full 24-hour period, is _n 24-hour periods.

     --eexxeecc _u_t_i_l_i_t_y [argument ...];
             True if the program named _u_t_i_l_i_t_y returns a zero value as its ex-
             it status.  Optional arguments may be passed to the utility.  The
             expression must be terminated by a semicolon (``;'').  If the
             string ``{}'' appears anywhere in the utility name or the argu-
             ments it is replaced by the pathname of the current file.
             _U_t_i_l_i_t_y will be executed from the directory from which ffiinndd was
             executed.

     --ffssttyyppee _t_y_p_e
             True if the file is contained in a file system of type _t_y_p_e. Two
             special file system types are recognized: ``local'' and ``rdon-
             ly''.  These do not describe actual file system types; the former
             matches any file system physically mounted on the system where
             the ffiinndd is being executed, and the latter matches any file sys-
             tem which is mounted read-only.

     --ggrroouupp _g_n_a_m_e
             True if the file belongs to the group _g_n_a_m_e. If _g_n_a_m_e is numeric
             and there is no such group name, then _g_n_a_m_e is treated as a group
             id.

     --iinnuumm _n
             True if the file has inode number _n.

     --lliinnkkss _n
             True if the file has _n links.

     --llss     This primary always evaluates to true.  The following information
             for the current file is written to standard output: its inode
             number, size in 512-byte blocks, file permissions, number of hard
             links, owner, group, size in bytes, last modification time, and
             pathname.  If the file is a block or character special file, the
             major and minor numbers will be displayed instead of the size in
             bytes.  If the file is a symbolic link, the pathname of the
             linked-to file will be displayed preceded by ``->''.  The format
             is identical to that produced by ``ls -dgils''.

     --mmttiimmee _n
             True if the difference between the file last modification time
             and the time ffiinndd was started, rounded up to the next full
             24-hour period, is _n 24-hour periods.

     --ookk _u_t_i_l_i_t_y[argument ...];
             The --ookk primary is identical to the --eexxeecc primary with the excep-
             tion that ffiinndd requests user affirmation for the execution of the
             utility by printing a message to the terminal and reading a re-
             sponse.  If the response is other than ``y'' the command is not
             executed and the value of the _o_k expression is false.

     --nnaammee _p_a_t_t_e_r_n
             True if the last component of the pathname being examined matches
             _p_a_t_t_e_r_n. Special shell pattern matching characters (``['', ``]'',
             ``*'', and ``?'')  may be used as part of _p_a_t_t_e_r_n. These charac-
             ters may be matched explicitly by escaping them with a backslash
             (``\'').

     --nneewweerr _f_i_l_e
             True if the current file has a more recent last modification time
             than _f_i_l_e.

     --nnoouusseerr
             True if the file belongs to an unknown user.

     --nnooggrroouupp
             True if the file belongs to an unknown group.

     --ppaatthh _p_a_t_t_e_r_n
             True if the pathname being examined matches _p_a_t_t_e_r_n. Special
             shell pattern matching characters (``['', ``]'', ``*'', and
             ``?'')  may be used as part of _p_a_t_t_e_r_n. These characters may be
             matched explicitly by escaping them with a backslash (``\'').
             Slashes (``/'') are treated as normal characters and do not have
             to be matched explicitly.

     --ppeerrmm [--_m_o_d_e]
             The _m_o_d_e may be either symbolic (see chmod(1))  or an octal num-
             ber.  If the mode is symbolic, a starting value of zero is as-
             sumed and the mode sets or clears permissions without regard to
             the process' file mode creation mask.  If the mode is octal, only
             bits 07777 (S_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 (``-'').

     --pprriinntt  This primary always evaluates to true.  It prints the pathname of
             the current file to standard output, followed by a newline char-
             acter.  If neither --eexxeecc, --llss, --ookk, nor --pprriinntt00 is specified, the
             given expression shall be effectively replaced by ((_g_i_v_e_n
             _e_x_p_r_e_s_s_i_o_n)) --pprriinntt.

     --pprriinntt00
             This primary always evaluates to true.  It prints the pathname of
             the current file to standard output, followed by a null charac-
             ter.

     --pprruunnee  This primary always evaluates to true.  It causes ffiinndd to not de-
             scend into the current file.  Note, the --pprruunnee primary has no ef-
             fect if the --dd option was specified.

     --ssiizzee _n[cc]
             True if the file's size, rounded up, in 512-byte blocks is _n. If
             _n is followed by a ``c'', then the primary is true if the file's
             size is _n bytes.

     --ttyyppee _t
             True if the file is of the specified type.  Possible file types
             are as follows:

                   bb     block special
                   cc     character special
                   dd     directory
                   ff     regular file
                   ll     symbolic link
                   pp     FIFO
                   ss     socket

     --uusseerr _u_n_a_m_e
             True if the file belongs to the user _u_n_a_m_e. If _u_n_a_m_e is numeric
             and there is no such user name, then _u_n_a_m_e is treated as a user
             id.

     All primaries which take a numeric argument allow the number to be pre-
     ceded by a plus sign (``+'') or a minus sign (``-'').  A preceding plus
     sign means ``more than n'', a preceding minus sign means ``less than n''
     and neither means ``exactly n'' .

OOPPEERRAATTOORRSS
     The primaries may be combined using the following operators.  The opera-
     tors are listed in order of decreasing precedence.

     ((_e_x_p_r_e_s_s_i_o_n))  This evaluates to true if the parenthesized expression
                   evaluates to true.

     !!_e_x_p_r_e_s_s_i_o_n   This is the unary NOT operator.  It evaluates to true if
                   the expression is false.

     _e_x_p_r_e_s_s_i_o_n --aanndd _e_x_p_r_e_s_s_i_o_n

     _e_x_p_r_e_s_s_i_o_n _e_x_p_r_e_s_s_i_o_n
                   The --aanndd 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.

     _e_x_p_r_e_s_s_i_o_n --oorr _e_x_p_r_e_s_s_i_o_n
                   The --oorr operator is the logical OR operator.  The expres-
                   sion 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 ffiinndd. Primaries
     which themselves take arguments expect each argument to be a separate ar-
     gument to ffiinndd.

EEXXAAMMPPLLEESS
     The following examples are shown as given to the shell:

     find  /  \!  -name  "*.c"  -print
            Print out a list of all the files whose names do not end in
            ``.c''.

     find  /  -newer  ttt  -user  wnj  -print
            Print out a list of all the files owned by user ``wnj'' that are
            newer than the file ``ttt''.

     find  /  \!  \(  -newer  ttt  -user  wnj  \)  -print
            Print out a list of all the files which are not both newer than
            ``ttt'' and owned by ``wnj''.

     find  /  \(  -newer  ttt  -or  -user wnj  \)  -print
            Print out a list of all the files that are either owned by ``wnj''
            or that are newer than ``ttt''.

SSEEEE AALLSSOO
     chmod(1),  locate(1),  stat(2),  fts(3),  getpwent(3),  getgrent(3),
     strmode(3),  symlink(7)

SSTTAANNDDAARRDDSS
     The ffiinndd utility syntax is a superset of the syntax specified by the IEEE
     Std1003.2 (``POSIX.2'') standard.

     The options and the --iinnuumm, --ffoollllooww, --ffssttyyppee, --lliinnkkss, --llss and --pprriinntt00 pri-
     maries are extensions to IEEE Std1003.2 (``POSIX.2'').

     Historically, the --dd, --ss and --xx options were implemented using the pri-
     maries ``-depth'', ``-follow'', and ``-xdev''.  These primaries always
     evaluated to true.  As they were really global variables that took effect
     before the traversal began, some legal expressions could have unexpected
     results.  An example is the expression ``-print -o -depth''.  As -print
     always evaluates to true, the standard order of evaluation implies that
     -depth would never be evaluated.  This is not the case.

     The operator ``-or'' was implemented as ``-o'', and the operator ``-and''
     was implemented as ``-a''.


     Historic implementations of the --eexxeecc and --ookk primaries did not replace
     the string ``{}'' in the utility name or the utility arguments if it had
     preceding or following non-whitespace characters.  This version replaces
     it no matter where in the utility name or arguments it appears.

BBUUGGSS
     The special characters used by ffiinndd 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 _e_x_p_r_e_s_s_i_o_n, it is difficult to specify files named ``-xdev'' or
     ``!''.  These problems are handled by the --ff option and the getopt(3)
     ``--'' construct.

BSD Experimental               October 19, 1994                              5
