home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 May / W2KPRK.iso / apps / posix / source / MAN / FIND.PRT < prev    next >
Text File  |  1999-11-17  |  11KB  |  265 lines

  1.                                                          FIND (1)
  2.  
  3. NAME
  4.  
  5.   find - walk a file hierarchy
  6.  
  7. SYNOPSIS
  8.  
  9.   find [ dsXx ] [ f ] [ file ] expression
  10. DESCRIPTION
  11.  
  12.   Find recursively descends the  directory  tree  for  each  file
  13. listed,  evaluating  an expression (composed of the ``primaries''
  14. and ``operands'' listed below) in terms of each file in the tree.
  15.   If file is a symbolic link referencing an  existing  file,  the
  16. directory tree referenced by the link is descended instead of the
  17. link itself.
  18.   The options are as follows:
  19.      d - The option causes find to perform a depth-first  traver-
  20.      sal,  i.e. directories are visited in post-order and all en-
  21.      tries in a directory will be acted on before  the  directory
  22.      itself.   By  default, find visits directories in pre-order,
  23.      i.e. before their contents.  Note,  the  default  is  not  a
  24.      breadth-first traversal.
  25.      f - The option  specifies  a  file  hierarchy  for  find  to
  26.      traverse.   File  hierarchies  may  also be specified as the
  27.      operands immediately following the options.
  28.      s - The option causes the file  information  and  file  type
  29.      (see  stat (2) ) returned for each symbolic link to be those
  30.      of the file referenced by the link, not the link itself.  If
  31.      the referenced file does not exist, the file information and
  32.      type will be for the link itself.
  33.      X - The option is a modification to permit
  34.  
  35.      to be safely used in conjunction with xargs (1) .  If a file
  36.      name contains any of the delimiting characters used by xargs
  37.      (,) a diagnostic message is displayed on standard error, and
  38.      the file is skipped.  The delimiting characters include sin-
  39.      gle (`` '  '')  and  double  (``  "  '')  quotes,  backslash
  40.      (``\''), space, tab and newline characters.
  41.      x - The option prevents find  from  descending  into  direc-
  42.      tories  that have a device number different than that of the
  43.      file from which the descent began.
  44. PRIMARIES
  45.  
  46.      -atime - True if the difference between the file last access
  47.      time  and  the time find was started, rounded up to the next
  48.      full 24-hour period, is n 24-hour periods.
  49.      -ctime - True if the difference between  the  time  of  last
  50.      change  of  file  status  information  and the time find was
  51.      started, rounded up to the next full 24-hour  period,  is  n
  52.      24-hour periods.
  53.      -exec - True if the program named  utility  returns  a  zero
  54.      value  as its exit status.  Optional arguments may be passed
  55.      to the utility.  The expression  must  be  terminated  by  a
  56.      semicolon (``;'').  If the string ``{}'' appears anywhere in
  57.      the utility name or the arguments  it  is  replaced  by  the
  58.      pathname of the current file.  Utility will be executed from
  59.      the directory from which find was executed.
  60.      -fstype - True if the file is contained in a file system  of
  61.      type   type  .  Currently  supported  types  are  ``local'',
  62.      ``mfs'', ``nfs'', ``pc'', ``rdonly'' and ``ufs''.  The types
  63.      ``local'' and ``rdonly'' are not specific file system types.
  64.      The former matches any file system physically mounted on the
  65.      system  where  the  find  is  being  executed and the latter
  66.      matches any file system which is mounted read-only.
  67.      -group - True if the file belongs to the group  gname  .  If
  68.      gname is numeric and there is no such group name, then gname
  69.      is treated as a group id.
  70.      -inum - True if the file has inode number n .
  71.      -links - True if the file has n links.
  72.      -ls - This primary always evaluates to true.  The  following
  73.      information for the current file is written to standard out-
  74.      put: its inode number, size in 512-byte blocks, file permis-
  75.      sions,  number  of  hard links, owner, group, size in bytes,
  76.      last modification time, and pathname.   If  the  file  is  a
  77.      block or character special file, the major and minor numbers
  78.      will be displayed instead of the size in bytes.  If the file
  79.      is  a symbolic link, the pathname of the linked-to file will
  80.      be displayed preceded by ``->''.  The format is identical to
  81.      that produced by ``ls -dgils''.
  82.      -mtime - True if the difference between the file last modif-
  83.      ication  time  and  the time find was started, rounded up to
  84.      the next full 24-hour period, is n 24-hour periods.
  85.      -ok - The primary is identical to the primary with  the  ex-
  86.      ception  that  find requests user affirmation for the execu-
  87.      tion of the utility by printing a message  to  the  terminal
  88.      and reading a response.  If the response is other than ``y''
  89.      the command is not executed and the value of the ok  expres-
  90.      sion is false.
  91.      -name - True if the last component of the pathname being ex-
  92.      amined  matches  pattern  .  Special  shell pattern matching
  93.      characters (``['', ``]'', ``*'', and ``?'') may be  used  as
  94.      part of pattern . These characters may be matched explicitly
  95.      by escaping them with a backslash (``\'').
  96.      -newer - True if the current file has  a  more  recent  last
  97.      modification time than file .
  98.      -nouser - True if the file belongs to an unknown user.
  99.      -nogroup - True if the file belongs to an unknown group.
  100.      -path - True if the pathname being examined matches  pattern
  101.      .  Special  shell pattern matching characters (``['', ``]'',
  102.      ``*'', and ``?'') may be used as part  of  pattern  .  These
  103.      characters may be matched explicitly by escaping them with a
  104.      backslash (``\'').  Slashes (``/'') are  treated  as  normal
  105.      characters and do not have to be matched explicitly.
  106.      -perm - The mode may be either symbolic (see chmod (1) )  or
  107.      an  octal number.  If the mode is symbolic, a starting value
  108.      of zero is assumed and the mode sets or  clears  permissions
  109.      without  regard to the process' file mode creation mask.  If
  110.      the mode is octal, only bits 07777 | | | | | of  the  file's
  111.      mode  bits  participate  in  the comparison.  If the mode is
  112.      preceded by a dash (``-''), this primary evaluates  to  true
  113.      if  at  least  all  of  the  bits in the mode are set in the
  114.      file's mode bits.  If the mode is not preceded  by  a  dash,
  115.      this  primary  evaluates to true if the bits in the mode ex-
  116.      actly match the file's mode bits.  Note, the first character
  117.      of a symbolic mode may not be a dash (``-'').
  118.      -print - This primary always evaluates to true.   It  prints
  119.      the  pathname  of  the current file to standard output.  The
  120.      expression is appended to the user specified  expression  if
  121.      neither or is specified.
  122.      -prune - This primary always evaluates to true.   It  causes
  123.      find  to  not descend into the current file.  Note, the pri-
  124.      mary has no effect if the option was specified.
  125.      -size - True if the file's size,  rounded  up,  in  512-byte
  126.      blocks  is n . If n is followed by a ``c'', then the primary
  127.      is true if the file's size is n bytes.
  128.      -type - True if the file is of the specified type.  Possible
  129.      file types are as follows:
  130.           b - block special
  131.           c - character special
  132.           d - directory
  133.           f - regular file
  134.           l - symbolic link
  135.           p - FIFO
  136.           s - socket
  137.        -user - True if the file belongs to the user  uname  .  If
  138.      uname  is numeric and there is no such user name, then uname
  139.      is treated as a user id.
  140.   All primaries which take a numeric argument allow the number to
  141. be  preceded  by  a plus sign (``+'') or a minus sign (``-'').  A
  142. preceding plus sign means ``more than n'', a preceding minus sign
  143. means ``less than n'' and neither means ``exactly n'' .
  144. OPERATORS
  145.  
  146.   The primaries may be combined using  the  following  operators.
  147. The operators are listed in order of decreasing precedence.
  148.      ( - This evaluates to true if the  parenthesized  expression
  149.      evaluates to true.
  150.        ! - This is the unary operator.  It evaluates to  true  if
  151.      the expression is false.
  152.        expression -
  153.      expression - The operator is the logical operator.  As it is
  154.      implied  by the juxtaposition of two expressions it does not
  155.      have to be specified.  The expression evaluates to  true  if
  156.      both  expressions  are  true.   The second expression is not
  157.      evaluated if the first expression is false.
  158.        expression - The operator is the  logical  operator.   The
  159.      expression  evaluates  to  true  if  either the first or the
  160.      second expression is true.  The  second  expression  is  not
  161.      evaluated if the first expression is true.
  162.   All operands and primaries must be separate arguments  to  find
  163. Primaries which themselves take arguments expect each argument to
  164. be a separate argument to find
  165. EXAMPLES
  166.  
  167.   The following examples are shown as given to the shell:
  168.      find  /  \!  -name  *.c  -print - Print out a  list  of  all
  169.      the files whose names do not end in ``.c''.
  170.      find  /  -newer  ttt  -user  wnj  -print - Print out a  list
  171.      of  all  the files owned by user ``wnj'' that are newer than
  172.      the file ``ttt''.
  173.      find  /  \!  \(  -newer  ttt  -user  wnj  \)  -print - Print
  174.      out  a  list  of all the files which are not both newer than
  175.      ``ttt'' and owned by ``wnj''.
  176.      find  /  \(  -newer  ttt  -or  -user wnj  \)  -print - Print
  177.      out a list of all the files that are either owned by ``wnj''
  178.      or that are newer than ``ttt''.
  179. SEE ALSO
  180.  
  181.   chmod (1) , sh (1) , test (1) , stat (2) , umask (2) , getpwent
  182. (3) , getgrent (3) , strmode (3)
  183. STANDARDS
  184.  
  185.   The find utility syntax is a superset of the  syntax  specified
  186. by the standard.
  187.   The and options and the and primaries are extensions to
  188.   Historically, the and options were implemented using  the  pri-
  189. maries  ``-depth'',  ``-follow'', and ``-xdev''.  These primaries
  190. always evaluated to true.  As they were really  global  variables
  191. that  took  effect before the traversal began, some legal expres-
  192. sions could have unexpected results.  An example is  the  expres-
  193. sion  ``-print  -o -depth''.  As -print always evaluates to true,
  194. the standard order of evaluation implies that -depth would  never
  195. be evaluated.  This is not the case.
  196.   The operator ``-or'' was implemented as ``-o'', and the  opera-
  197. tor ``-and'' was implemented as ``-a''.
  198.   Historic implementations of the and primaries did  not  replace
  199. the string ``{}'' in the utility name or the utility arguments if
  200. it had preceding or following  non-whitespace  characters.   This
  201. version  replaces it no matter where in the utility name or argu-
  202. ments it appears.
  203. BUGS
  204.  
  205.   The special characters used by find are also special characters
  206. to  many  shell  programs.   In particular, the characters ``*'',
  207. ``['', ``]'', ``?'', ``('', ``)'', ``!'',  ``\''  and  ``;''  may
  208. have to be escaped from the shell.
  209.   As there is no delimiter separating options and file  names  or
  210. file  names and the expression , it is difficult to specify files
  211. named ``-xdev'' or ``!''.  These problems are handled by the  op-
  212. tion and the getopt (3) ``--'' construct.
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.