COHERENT manpages
This page displays the COHERENT manpage for find [Search for files satisfying a pattern].
List of available manpages
Index
find -- Command
Search for files satisfying a pattern
find directory ... [expression ...]
find traverses each given directory, testing each file or subdirectory
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 execution or
printing (-print, -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:
-atime n
Match if the file was accessed in the last n days.
-ctime n
Match if the i-node associated with the file was changed in the
last n days, as by chmod.
-exec command
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 `{}'.
-group name
Match if the file is owned by group name. If name is a number, the
owner must have that group number.
-inum n
Match if the file is associated with i-number n.
-links n
Match if the number of links to the file is n.
-mtime n
Match if the most recent modification to the file was n days ago.
-name pattern
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.
-newer file
Match if the file is newer than file.
-nop Always match; does nothing.
-ok command
Same as -exec above, except prompt interactively and only executes
command if the user types response `y'.
-perm octal
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.
-print Always match; print the file name.
-size n
Match if the file is n blocks in length; a block is 512 bytes long.
-type 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).
-user name
Match if the file is owned by user name. If name is a number, the
owner must have that user number.
exp1 exp2
Match if both expressions match. find evaluates exp2 only if exp1
matches.
exp1 -a exp2
Match if both expressions match, as above.
exp1 -o exp2
Match if either expression matches. find evaluates exp2 only if
exp1 does not match.
! exp Match if the expression does not match.
( exp )
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:
find /usr/fred
The following, more complicated find command prints out information on all
core and object (.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 {} \;
Finally, the following example implements a simple tool for keeping files
on two COHERENT systems in synch with each other. find reads directory src
and passes to uucp the names of all files that are newer than file
last_upload. It then uses the command touch to update the date on
last_upload, to use it as a marker of when the last upload was performed.
find $HOME/src -type f -newer last_upload | while read filename
do
uucp -r -nyou $filename yoursystem!~/
echo Queued file $filename to yoursystem ...
done | mail somebodyorother
touch last_upload
See Also
chmod,
commands,
ls,
sh,
srcpath,
test