Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ find(C) — OpenDesktop 1.1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cpio(C)

sh(C)

stat(S)

test(C)


     FIND(C)                              UNIX System V



     Name
          find - finds files


     Syntax
          find pathname-list expression


     Description
          The find command is used to find files  matching  a  certain
          set  of  selection  criteria.  find recursively descends the
          directory hierarchy for each pathname in  the  pathname-list
          (i.e.,  one  or  more  pathnames) seeking files that match a
          Boolean expression written in the primaries given below.


     Expressions
          For each file  encountered,  find  evaluates  the  specified
          expression,  formed  of one or more of the following primary
          expressions, which may evaluate as true or  false.   In  the
          descriptions,  the  argument  n is used as a decimal integer
          where +n means more than n, -n means less than n and n means
          exactly n.

          -name file      True if file matches the current file  name.
                          Normal  shell argument syntax may be used if
                          escaped (watch out for the left bracket ([),
                          the question mark (?)  and the star (*)).

          -perm onum      True if the file  permission  flags  exactly
                          match  onum  (see  chmod(C)).   If  onum  is
                          prefixed by a minus sign,  all  other  modes
                          become significant (see mknod(S)), including
                          the file type, setuid,  setgid,  and  sticky
                          bits  rather  than  just  read/write/execute
                          modes for owner/group/other.

          -type x         True if the type of the file is x,  where  x
                          is b for block special file, c for character
                          special file, d for directory, p  for  named
                          pipe  (first-in-first-out), or f for regular
                          file.

          -links n        True if the file has n links.

          -size n[c]      True if the file is n blocks long (512 bytes
                          per  block).   If  n is followed by a c, the
                          size is in characters.  write permission.

          -mount          Always true; restricts  the  search  to  the
                          file   system   containing   the   directory
                          specified, or if no directory was specified,
                          the current directory.

          -local          True if the file physically resides  on  the
                          local system.

          -inum num       True if the file's inode is  num.   This  is
                          useful  for  locating  files  with  matching
                          inodes.

          -user uname     True if the file belongs to the user  uname.
                          If uname is numeric and does not appear as a
                          login name in the /etc/passwd  file,  it  is
                          taken as a user ID.

          -group gname    True if the file belongs to the group gname.
                          If  gname  is numeric and does not appear in
                          the /etc/group file as a group name,  it  is
                          taken as a group ID.

          -atime n        True if the file was last  accessed  n  days
                          ago.

          -mtime n        True if  the  data  in  the  file  was  last
                          modified n days ago.

          -ctime n        True if the file's status was  last  changed
                          (i.e. created or modified) n days ago.

          -exec cmd       Executes shell command cmd.  The end of  cmd
                          must  be punctuated by an escaped semicolon.
                          A command argument {}  is  replaced  by  the
                          current path name.  True if the executed cmd
                          returns a zero value as  exit  status  (most
                          commands  return  a zero value on successful
                          completion and a non-zero value if an  error
                          is encountered).

          -ok cmd         Like -exec except that the generated command
                          line  is printed with a question mark first,
                          and is executed only if the user responds by
                          typing y.

          -cpio device    Writes the current file on device in cpio(F)
                          format (5120-byte records).  Always true.

          -depth          Causes all entries  in  a  directory  to  be
                          acted  upon  before  the  directory  itself.
                          This can be useful when used with cpio(C) or
                          the   -cpio  expression  to  transfer  files
                          located   in   directories   without   write
                          permission.  Always true.

          -print          Causes the current path name to be  printed.
                          This  option is used to create a list of all
                          files matched  by  the  previous  primaries.
                          Always true.

          -newer file     True if the current file has  been  modified
                          more recently than the argument file.

          ( expression )  True  if  the  parenthesized  expression  is
                          true.   Usually  used  with  the -o operator
                          (see  below),  parentheses  are   used   for
                          grouping.   Parentheses  are  special to the
                          shell and must be escaped.

          The primaries may be combined using the following  operators
          (in order of decreasing precedence):

          !  The ! operator specifies the negation of the next primary
             (i.e.,  !  -newer file is true if the current file is not
             newer than file.).  This is the equivalent of the logical
             ``not'' operator.

          -o Placing the -o operator between two primaries creates  an
             expression that is true if either of the two primaries is
             true.  It should be used with parentheses (i.e., \( -perm
             644  -o  -perm  664  \)  is  true if the current file has
             permissions 644 or  664).   This  is  equivalent  to  the
             logical ``inclusive or'' operator.

          Note that placing two primaries next to each  other  is  the
          equivalent of the logical ``and'' operation.  The precedence
          of this operation is less than that of the  !  operator  but
          greater than that of the -o operator.


     Examples
          The following command searches for files named  chapter1  in
          the current directory and all directories below it and sends
          the pathname of any such files  it  finds  to  the  standard
          output:

          find . -name chapter1 -print

          The following removes all files named  core  or  with  names
          ending in .out that have not been accessed in the last seven
          days.

          find / \( -name core -o -name "*.out" \) -atime +7 -exec rm {} \;

     Files
          /etc/passwd   User names and uids

          /etc/group    Group names and gids


     See Also
          cpio(C)(F), sh(C), stat(S), test(C)


     Standards Conformance
          find is conformant with:
          AT&T SVID Issue 2, Select Code 307-127;
          and The X/Open Portability Guide II of January 1987.


     (printed 2/15/90)                                    FIND(C)








































































































































































































































































































































































































































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