unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (SunOS-4.1.3)
Page:
Section:
Apropos / Subsearch:
optional field

FIND(1)                     General Commands Manual                    FIND(1)



NAME
       find - find files by name, or by other characteristics

SYNOPSIS
       find pathname-list expression
       find component

DESCRIPTION
       find  recursively descends the directory hierarchy for each pathname in
       the pathname-list, seeking files that match a logical expression  writ-
       ten using the operators listed below.

       find  does  not follow symbolic links to other files or directories; it
       applies the selection criteria to the symbolic links themselves, as  if
       they  were  ordinary  files  (see  ln(1V) for a description of symbolic
       links).

       If the fast-find feature is enabled, find displays pathnames in which a
       filename component occurs.

USAGE
   Operators
       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.

       -fstype type   True if the filesystem to which the file belongs  is  of
                      type type, where type is typically 4.2 or nfs.

       -name filename True  if  the filename argument matches the current file
                      name.  Shell argument syntax  can  be  used  if  escaped
                      (watch out for [, ? and *).

       -perm onum     True  if  the  file  permission  flags exactly match the
                      octal number onum (see chmod(1V)).  If onum is  prefixed
                      by  a minus sign, more flag bits (017777, see chmod(1V))
                      become  significant  and   the   flags   are   compared:
                      (flags&&onum)==onum.

       -prune         Always  yields true.  Has the side effect of pruning the
                      search tree at the file.  That is, if the  current  path
                      name  is  a  directory,  find will not descend into that
                      directory.

       -type c        True if the type of the file is c, where c is one of:

                             b      for block special file c
                             c      for character special file
                             d      for directory
                             f      for plain file
                             p      for named pipe (FIFO)
                             l      for symbolic link
                             s      for socket

       -links n       True if the file has n links.

       -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 database, it is taken as a user ID.

       -nouser        True  if  the  file  belongs  to  a  user  not  in   the
                      /etc/passwd database.

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

       -nogroup       True  if  the  file  belongs  to  a  group  not  in  the
                      /etc/group database.

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

       -inum n        True if the file has inode number n.

       -atime n       True if the file has been accessed in n days.
                      Note:  the  access time of directories in path-name-list
                      is changed by find itself.

       -mtime n       True if the file has been modified in n days.

       -ctime n       True if the file has been changed in n days.   "Changed"
                      means  either  that  the  file has been modified or some
                      attribute of the file (its owner, its group, the  number
                      of links to it, etc.) has been changed.

       -exec command  True  if  the  executed  command returns a zero value as
                      exit status.  The end of command must be  punctuated  by
                      an escaped semicolon.  A command argument {} is replaced
                      by the current pathname.

       -ok command    Like -exec except that the generated command is  written
                      on  the standard output, then the standard input is read
                      and the command executed only upon response y.

       -print         Always true; the current pathname is printed.

       -ls            Always true; prints current pathname together  with  its
                      associated  statistics.   These  include  (respectively)
                      inode number, size in kilobytes (1024 bytes), protection
                      mode,  number of hard links, user, group, size in bytes,
                      and modification time.  If the file is  a  special  file
                      the  size field will instead contain the major and minor
                      device numbers.  If the file  is  a  symbolic  link  the
                      pathname  of  the  linked-to file is printed preceded by
                      `->>'.  The format is identical to that of ls -gilds (see
                      ls(1V)).
                      Note:  formatting  is done internally, without executing
                      the ls program.

       -cpio device   Always true; write the current file on device in cpio(5)
                      format (5120-byte records).

       -ncpio device  Always true; write the current file on device in cpio -c
                      format (5120-byte records).

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

       -xdev          Always  true;  find  does  not traverse down into a file
                      system different from the one on which current  argument
                      pathname resides.

       -depth         Always true; find descends the directory hierarchy, act-
                      ing on the entries in a directory before acting  on  the
                      directory  itself.  This can be useful when find is used
                      with cpio(1) to transfer files  that  are  contained  in
                      directories without write permission.

       (expression)   True if the parenthesized expression is true.
                      Note:  Parentheses  are special to the shell and must be
                      escaped.

       !primary       True if the primary is false (!  is the unary not opera-
                      tor).

       primary1 [ -a ] primary2
                      True  if both primary1 and primary2 are true.  The -a is
                      not required.  It is implied by the juxtaposition of two
                      primaries.

       primary1 -o primary2
                      True  if  either primary1 or primary2 is true (-o is the
                      or operator).

   Fast-Find
       The fast-find feature is enabled by  the  presence  of  the  find.codes
       database  in  /usr/lib/find.   You must be root to build or update this
       database by running the updatedb script in that  same  directory.   You
       may wish to modify the updatedb script to suit your needs.

       An  alternate  database can be specified by setting the FCODES environ-
       ment variable.

EXAMPLE
       In our local development system, we keep a file called TIMESTAMP in all
       the manual page directories.  Here is how to find all entries that have
       been updated since TIMESTAMP was created:
              example% find /usr/share/man/man2 -newer /usr/share/man/man2/TIMESTAMP -print
              /usr/share/man/man2
              /usr/share/man/man2/socket.2
              /usr/share/man/man2/mmap.2
              example%

       To find all the files called intro.ms starting from the current  direc-
       tory:
              example% find . -name intro.ms -print
              ./manuals/assembler/intro.ms
              ./manuals/sun.core/intro.ms
              ./manuals/driver.tut/intro.ms
              ./manuals/sys.manager/uucp.impl/intro.ms
              ./supplements/general.works/unix.introduction/intro.ms
              ./supplements/programming.tools/sccs/intro.ms
              example%

       To  recursively  print  all  files  names  in the current directory and
       below, but skipping SCCS directories:
              example% find . -name SCCS -prune -o -print
              example%

       To recursively print all files  names  in  the  current  directory  and
       below,  skipping the contents of SCCS directories, but printing out the
       SCCS directory name:
              example% find . -print -name SCCS -prune
              example%

       To remove files beneath your home directory named  a.out  or  *.o  that
       have not been accessed for a week and that are not mounted using NFS:
              example% cd
              example% find . \( -name a.out -o -name '*.o' \) -atime +7 -exec rm {} \; -o -fstype nfs -prune

FILES
       /usr/lib/find/find.codes
                           database for fast find
       /usr/lib/find/updatedb
                           script to update fast-find database
       /usr/lib/find/code  fast-find database utilities
       /usr/lib/find/bigram
ENVIRONMENT
       FCODES              alternate database for fast find

SEE ALSO
       chmod(1V), cpio(1), ln(1V), ls(1V), sh(1), test(1V), cpio(5), fs(5)



                                6 January 1989                         FIND(1)