

find                         Command                         find




Search for files satisfying a pattern

ffiinndd _d_i_r_e_c_t_o_r_y ... [_e_x_p_r_e_s_s_i_o_n ...]

find traverses  each given directory,  testing each file  or sub-
directory  found with  the expression part  of the  command line.
The test  can be  the basis for  deciding whether to  process the
file with a given command.

If the  command line specifies no expression  or specifies no ex-
ecution  or printing  (-pprriinntt, -exec,  or  -ok), by  default find
prints the pathnames of the files found.

In the  following, file means any  file: directory, special file,
ordinary  file,  and so  on.   Numbers represented  by  n may  be
optionally  prefixed  by a  `+'  or `-'  sign  to signify  values
greater than n or less than n, respectively.

find recognizes the following expression primitives:

-aattiimmee _n
        Match if the file was accessed in the last n days.

-ccttiimmee _n
        Match if the i-node associated with  the file was changed
        in the last n days, as by chmod.

-eexxeecc _c_o_m_m_a_n_d
        Match if command  executes successfully (has  a zero exit
        status).  The command consists of the following arguments
        to find, terminated  by a  semicolon `;' (escaped  to get
        past the shell).   find substitutes the  current pathname
        being tested for any argument of the form `{}'.

-ggrroouupp _n_a_m_e
        Match if the file  is owned by group name.   If name is a
        number, the owner must have that group number.

-iinnuumm _n
        Match if the file is associated with i-number n.

-lliinnkkss _n
        Match if the number of links to the file is n.

-mmttiimmee _n
        Match if the most  recent modification to the  file was n
        days ago.

-nnaammee _p_a_t_t_e_r_n
        Match if the file name corresponds  to pattern, which may
        include the  special  characters  `*',  `?', and  `[...]'
        recognized by the shell sh.  The pattern matches only the
        part of the file name after any slash (`/') characters.



COHERENT Lexicon                                           Page 1




find                         Command                         find



-nneewweerr _f_i_l_e
        Match if the file is newer than file.

-nnoopp    Always match; does nothing.

-ookk _c_o_m_m_a_n_d
        Same as -exec above, except prompt interactively and only
        executes command if the user types response `y'.

-ppeerrmm _o_c_t_a_l
        Match if owner, group, and other  permissions of the file
        are the octal  bit pattern, as described  in chmod.  When
        octal begins with a `-' character, more of the permission
        bits (setuid, setgid, and sticky bit) become significant.

-pprriinntt  Always match; print the file name.

-ssiizzee _n
        Match if the file  is n blocks in length;  a block is 512
        bytes long.

-ttyyppee _c
        Match if the type  of the file is c,  chosen from the set
        bcdfmp (for block special,  character special, directory,
        ordinary file, multiplexed file, or pipe, respectively).

-uusseerr _n_a_m_e
        Match if the  file is owned  by user name.  If  name is a
        number, the owner must have that user number.

_e_x_p_1 _e_x_p_2
        Match if  both  expressions match.   find evaluates  exp2
        only if exp1 matches.

_e_x_p_1 -aa _e_x_p_2
        Match if both expressions match, as above.

_e_x_p_1 -oo _e_x_p_2
        Match if either expression  matches.  find evaluates exp2
        only if exp1 does not match.

! _e_x_p   Match if the expression does not match.

( _e_x_p )
        Parentheses are available for expression grouping.

***** Examples *****

A find command to print the names of all files and directories in
user fred's directory is:







COHERENT Lexicon                                           Page 2




find                         Command                         find



        find /usr/fred


The following, more  complicated find command prints out informa-
tion on all core and object (.oo) files that have not been changed
for a day.  Because some  characters are special both to find and
sh, they must be escaped  with `\' to avoid interpretation by the
shell.


        find / \( -name core -o -name \*.o \) -mtime +1 \
        -exec ls -l {} \;


***** See Also *****

chmod, commands, ls, sh, test








































COHERENT Lexicon                                           Page 3


