Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ () — Coherent 3.1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought


find                         Command                         find




Search for files satisfying a pattern

find directory ... [expression ...]

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  (-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.



COHERENT Lexicon                                           Page 1



find                         Command                         find



-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:







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) 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


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026