|
|
coherent
find Command find
Search for files satisfying a pattern
ffiinndd _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 (-pprriinntt, -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:
-aattiimmee _n
Match if the file was accessed in the last n days.
-ccttiimmee _n
Match if the i-node associated with the file was changed
in the last n days, as by chmod.
-eexxeecc _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 `{}'.
-ggrroouupp _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.
-iinnuumm _n
Match if the file is associated with i-number n.
-lliinnkkss _n
Match if the number of links to the file is n.
-mmttiimmee _n
Match if the most recent modification to the file was n
days ago.
-nnaammee _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
-nneewweerr _f_i_l_e
Match if the file is newer than file.
-nnoopp Always match; does nothing.
-ookk _c_o_m_m_a_n_d
Same as -exec above, except prompt interactively and only
executes command if the user types response `y'.
-ppeerrmm _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.
-pprriinntt Always match; print the file name.
-ssiizzee _n
Match if the file is n blocks in length; a block is 512
bytes long.
-ttyyppee _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).
-uusseerr _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 -aa _e_x_p_2
Match if both expressions match, as above.
_e_x_p_1 -oo _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 (.oo) 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
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.