home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / findutils-4.1-bin.lha / info / find.info-1 (.txt) < prev    next >
GNU Info File  |  1996-10-12  |  51KB  |  1,042 lines

  1. This is Info file find.info, produced by Makeinfo-1.63 from the input
  2. file /ade-src/fsf/findutils/doc/find.texi.
  3. START-INFO-DIR-ENTRY
  4. * Finding Files: (find).        Listing and operating on files
  5.                                 that match certain criteria.
  6. END-INFO-DIR-ENTRY
  7.    This file documents the GNU utilities for finding files that match
  8. certain criteria and performing various operations on them.
  9.    Copyright (C) 1994 Free Software Foundation, Inc.
  10.    Permission is granted to make and distribute verbatim copies of this
  11. manual provided the copyright notice and this permission notice are
  12. preserved on all copies.
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided that
  15. the entire resulting derived work is distributed under the terms of a
  16. permission notice identical to this one.
  17.    Permission is granted to copy and distribute translations of this
  18. manual into another language, under the above conditions for modified
  19. versions, except that this permission notice may be stated in a
  20. translation approved by the Foundation.
  21. File: find.info,  Node: Top,  Next: Introduction,  Up: (dir)
  22.    This file documents the GNU utilities for finding files that match
  23. certain criteria and performing various actions on them.  This is
  24. edition 1.1, for `find' version 4.1.
  25. * Menu:
  26. * Introduction::                Summary of the tasks this manual describes.
  27. * Finding Files::               Finding files that match certain criteria.
  28. * Actions::                     Doing things to files you have found.
  29. * Common Tasks::                Solutions to common real-world problems.
  30. * Databases::                   Maintaining file name databases.
  31. * File Permissions::            How to control access to files.
  32. * Reference::                   Summary of how to invoke the programs.
  33. * Primary Index::               The components of `find' expressions.
  34. File: find.info,  Node: Introduction,  Next: Finding Files,  Prev: Top,  Up: Top
  35. Introduction
  36. ************
  37.    This manual shows how to find files that meet criteria you specify,
  38. and how to perform various actions on the files that you find.  The
  39. principal programs that you use to perform these tasks are `find',
  40. `locate', and `xargs'.  Some of the examples in this manual use
  41. capabilities specific to the GNU versions of those programs.
  42.    GNU `find' was originally written by Eric Decker, with enhancements
  43. by David MacKenzie, Jay Plett, and Tim Wood.  GNU `xargs' was
  44. originally written by Mike Rendell, with enhancements by David
  45. MacKenzie.  GNU `locate' and its associated utilities were originally
  46. written by James Woods, with enhancements by David MacKenzie.  The idea
  47. for `find -print0' and `xargs -0' came from Dan Bernstein.  Many other
  48. people have contributed bug fixes, small improvements, and helpful
  49. suggestions.  Thanks!
  50.    Mail suggestions and bug reports for these programs to
  51. `bug-gnu-utils@prep.ai.mit.edu'.  Please include the version number,
  52. which you can get by running `find --version'.
  53. * Menu:
  54. * Scope::
  55. * Overview::
  56. * find Expressions::
  57. File: find.info,  Node: Scope,  Next: Overview,  Up: Introduction
  58. Scope
  59. =====
  60.    For brevity, the word "file" in this manual means a regular file, a
  61. directory, a symbolic link, or any other kind of node that has a
  62. directory entry.  A directory entry is also called a "file name".  A
  63. file name may contain some, all, or none of the directories in a path
  64. that leads to the file.  These are all examples of what this manual
  65. calls "file names":
  66.      parser.c
  67.      README
  68.      ./budget/may-94.sc
  69.      fred/.cshrc
  70.      /usr/local/include/termcap.h
  71.    A "directory tree" is a directory and the files it contains, all of
  72. its subdirectories and the files they contain, etc.  It can also be a
  73. single non-directory file.
  74.    These programs enable you to find the files in one or more directory
  75. trees that:
  76.    * have names that contain certain text or match a certain pattern;
  77.    * are links to certain files;
  78.    * were last used during a certain period of time;
  79.    * are within a certain size range;
  80.    * are of a certain type (regular file, directory, symbolic link,
  81.      etc.);
  82.    * are owned by a certain user or group;
  83.    * have certain access permissions;
  84.    * contain text that matches a certain pattern;
  85.    * are within a certain depth in the directory tree;
  86.    * or some combination of the above.
  87.    Once you have found the files you're looking for (or files that are
  88. potentially the ones you're looking for), you can do more to them than
  89. simply list their names.  You can get any combination of the files'
  90. attributes, or process the files in many ways, either individually or in
  91. groups of various sizes.  Actions that you might want to perform on the
  92. files you have found include, but are not limited to:
  93.    * view or edit
  94.    * store in an archive
  95.    * remove or rename
  96.    * change access permissions
  97.    * classify into groups
  98.    This manual describes how to perform each of those tasks, and more.
  99. File: find.info,  Node: Overview,  Next: find Expressions,  Prev: Scope,  Up: Introduction
  100. Overview
  101. ========
  102.    The principal programs used for making lists of files that match
  103. given criteria and running commands on them are `find', `locate', and
  104. `xargs'.  An additional command, `updatedb', is used by system
  105. administrators to create databases for `locate' to use.
  106.    `find' searches for files in a directory hierarchy and prints
  107. information about the files it found.  It is run like this:
  108.      find [FILE...] [EXPRESSION]
  109. Here is a typical use of `find'.  This example prints the names of all
  110. files in the directory tree rooted in `/usr/src' whose name ends with
  111. `.c' and that are larger than 100 Kilobytes.
  112.      find /usr/src -name '*.c' -size +100k -print
  113.    `locate' searches special file name databases for file names that
  114. match patterns.  The system administrator runs the `updatedb' program
  115. to create the databases.  `locate' is run like this:
  116.      locate [OPTION...] PATTERN...
  117. This example prints the names of all files in the default file name
  118. database whose name ends with `Makefile' or `makefile'.  Which file
  119. names are stored in the database depends on how the system
  120. administrator ran `updatedb'.
  121.      locate '*[Mm]akefile'
  122.    The name `xargs', pronounced EX-args, means "combine arguments."
  123. `xargs' builds and executes command lines by gathering together
  124. arguments it reads on the standard input.  Most often, these arguments
  125. are lists of file names generated by `find'.  `xargs' is run like this:
  126.      xargs [OPTION...] [COMMAND [INITIAL-ARGUMENTS]]
  127. The following command searches the files listed in the file `file-list'
  128. and prints all of the lines in them that contain the word `typedef'.
  129.      xargs grep typedef < file-list
  130. File: find.info,  Node: find Expressions,  Prev: Overview,  Up: Introduction
  131. `find' Expressions
  132. ==================
  133.    The expression that `find' uses to select files consists of one or
  134. more "primaries", each of which is a separate command line argument to
  135. `find'.  `find' evaluates the expression each time it processes a file.
  136. An expression can contain any of the following types of primaries:
  137. "options"
  138.      affect overall operation rather than the processing of a specific
  139.      file;
  140. "tests"
  141.      return a true or false value, depending on the file's attributes;
  142. "actions"
  143.      have side effects and return a true or false value; and
  144. "operators"
  145.      connect the other arguments and affect when and whether they are
  146.      evaluated.
  147.    You can omit the operator between two primaries; it defaults to
  148. `-and'.  *Note Combining Primaries With Operators::, for ways to
  149. connect primaries into more complex expressions.  If the expression
  150. contains no actions other than `-prune', `-print' is performed on all
  151. files for which the entire expression is true (*note Print File
  152. Name::.).
  153.    Options take effect immediately, rather than being evaluated for each
  154. file when their place in the expression is reached.  Therefore, for
  155. clarity, it is best to place them at the beginning of the expression.
  156.    Many of the primaries take arguments, which immediately follow them
  157. in the next command line argument to `find'.  Some arguments are file
  158. names, patterns, or other strings; others are numbers.  Numeric
  159. arguments can be specified as
  160.      for greater than N,
  161.      for less than N,
  162.      for exactly N.
  163. File: find.info,  Node: Finding Files,  Next: Actions,  Prev: Introduction,  Up: Top
  164. Finding Files
  165. *************
  166.    By default, `find' prints to the standard output the names of the
  167. files that match the given criteria.  *Note Actions::, for how to get
  168. more information about the matching files.
  169. * Menu:
  170. * Name::
  171. * Links::
  172. * Time::
  173. * Size::
  174. * Type::
  175. * Owner::
  176. * Permissions::
  177. * Contents::
  178. * Directories::
  179. * Filesystems::
  180. * Combining Primaries With Operators::
  181. File: find.info,  Node: Name,  Next: Links,  Up: Finding Files
  182.    Here are ways to search for files whose name matches a certain
  183. pattern.  *Note Shell Pattern Matching::, for a description of the
  184. PATTERN arguments to these tests.
  185.    Each of these tests has a case-sensitive version and a
  186. case-insensitive version, whose name begins with `i'.  In a
  187. case-insensitive comparison, the patterns `fo*' and `F??' match the
  188. file names `Foo', `FOO', `foo', `fOo', etc.
  189. * Menu:
  190. * Base Name Patterns::
  191. * Full Name Patterns::
  192. * Fast Full Name Search::
  193. * Shell Pattern Matching::      Wildcards used by these programs.
  194. File: find.info,  Node: Base Name Patterns,  Next: Full Name Patterns,  Up: Name
  195. Base Name Patterns
  196. ------------------
  197.  - Test: -name PATTERN
  198.  - Test: -iname PATTERN
  199.      True if the base of the file name (the path with the leading
  200.      directories removed) matches shell pattern PATTERN.  For `-iname',
  201.      the match is case-insensitive.  To ignore a whole directory tree,
  202.      use `-prune' (*note Directories::.).  As an example, to find
  203.      Texinfo source files in `/usr/local/doc':
  204.           find /usr/local/doc -name '*.texi'
  205. File: find.info,  Node: Full Name Patterns,  Next: Fast Full Name Search,  Prev: Base Name Patterns,  Up: Name
  206. Full Name Patterns
  207. ------------------
  208.  - Test: -path PATTERN
  209.  - Test: -ipath PATTERN
  210.      True if the entire file name, starting with the command line
  211.      argument under which the file was found, matches shell pattern
  212.      PATTERN.  For `-ipath', the match is case-insensitive.  To ignore
  213.      a whole directory tree, use `-prune' rather than checking every
  214.      file in the tree (*note Directories::.).
  215.  - Test: -regex EXPR
  216.  - Test: -iregex EXPR
  217.      True if the entire file name matches regular expression EXPR.
  218.      This is a match on the whole path, not a search.  For example, to
  219.      match a file named `./fubar3', you can use the regular expression
  220.      `.*bar.' or `.*b.*3', but not `b.*r3'.  *Note Syntax of Regular
  221.      Expressions: (emacs)Regexps, for a description of the syntax of
  222.      regular expressions.  For `-iregex', the match is case-insensitive.
  223. File: find.info,  Node: Fast Full Name Search,  Next: Shell Pattern Matching,  Prev: Full Name Patterns,  Up: Name
  224. Fast Full Name Search
  225. ---------------------
  226.    To search for files by name without having to actually scan the
  227. directories on the disk (which can be slow), you can use the `locate'
  228. program.  For each shell pattern you give it, `locate' searches one or
  229. more databases of file names and displays the file names that contain
  230. the pattern.  *Note Shell Pattern Matching::, for details about shell
  231. patterns.
  232.    If a pattern is a plain string--it contains no
  233. metacharacters--`locate' displays all file names in the database that
  234. contain that string.  If a pattern contains metacharacters, `locate'
  235. only displays file names that match the pattern exactly.  As a result,
  236. patterns that contain metacharacters should usually begin with a `*',
  237. and will most often end with one as well.  The exceptions are patterns
  238. that are intended to explicitly match the beginning or end of a file
  239. name.
  240.    The command
  241.      locate PATTERN
  242.    is almost equivalent to
  243.      find DIRECTORIES -name PATTERN
  244.    where DIRECTORIES are the directories for which the file name
  245. databases contain information.  The differences are that the `locate'
  246. information might be out of date, and that `locate' handles wildcards
  247. in the pattern slightly differently than `find' (*note Shell Pattern
  248. Matching::.).
  249.    The file name databases contain lists of files that were on the
  250. system when the databases were last updated.  The system administrator
  251. can choose the file name of the default database, the frequency with
  252. which the databases are updated, and the directories for which they
  253. contain entries.
  254.    Here is how to select which file name databases `locate' searches.
  255. The default is system-dependent.
  256. `--database=PATH'
  257. `-d PATH'
  258.      Instead of searching the default file name database, search the
  259.      file name databases in PATH, which is a colon-separated list of
  260.      database file names.  You can also use the environment variable
  261.      `LOCATE_PATH' to set the list of database files to search.  The
  262.      option overrides the environment variable if both are used.
  263. File: find.info,  Node: Shell Pattern Matching,  Prev: Fast Full Name Search,  Up: Name
  264. Shell Pattern Matching
  265. ----------------------
  266.    `find' and `locate' can compare file names, or parts of file names,
  267. to shell patterns.  A "shell pattern" is a string that may contain the
  268. following special characters, which are known as "wildcards" or
  269. "metacharacters".
  270.    You must quote patterns that contain metacharacters to prevent the
  271. shell from expanding them itself.  Double and single quotes both work;
  272. so does escaping with a backslash.
  273.      Matches any zero or more characters.
  274.      Matches any one character.
  275. `[STRING]'
  276.      Matches exactly one character that is a member of the string
  277.      STRING.  This is called a "character class".  As a shorthand,
  278.      STRING may contain ranges, which consist of two characters with a
  279.      dash between them.  For example, the class `[a-z0-9_]' matches a
  280.      lowercase letter, a number, or an underscore.  You can negate a
  281.      class by placing a `!' or `^' immediately after the opening
  282.      bracket.  Thus, `[^A-Z@]' matches any character except an
  283.      uppercase letter or an at sign.
  284.      Removes the special meaning of the character that follows it.  This
  285.      works even in character classes.
  286.    In the `find' tests that do shell pattern matching (`-name',
  287. `-path', etc.), wildcards in the pattern do not match a `.' at the
  288. beginning of a file name.  This is not the case for `locate'.  Thus,
  289. `find -name '*macs'' does not match a file named `.emacs', but `locate
  290. '*macs'' does.
  291.    Slash characters have no special significance in the shell pattern
  292. matching that `find' and `locate' do, unlike in the shell, in which
  293. wildcards do not match them.  Therefore, a pattern `foo*bar' can match
  294. a file name `foo3/bar', and a pattern `./sr*sc' can match a file name
  295. `./src/misc'.
  296. File: find.info,  Node: Links,  Next: Time,  Prev: Name,  Up: Finding Files
  297. Links
  298. =====
  299.    There are two ways that files can be linked together.  "Symbolic
  300. links" are a special type of file whose contents are a portion of the
  301. name of another file.  "Hard links" are multiple directory entries for
  302. one file; the file names all have the same index node ("inode") number
  303. on the disk.
  304. * Menu:
  305. * Symbolic Links::
  306. * Hard Links::
  307. File: find.info,  Node: Symbolic Links,  Next: Hard Links,  Up: Links
  308. Symbolic Links
  309. --------------
  310.  - Test: -lname PATTERN
  311.  - Test: -ilname PATTERN
  312.      True if the file is a symbolic link whose contents match shell
  313.      pattern PATTERN.  For `-ilname', the match is case-insensitive.
  314.      *Note Shell Pattern Matching::, for details about the PATTERN
  315.      argument.  So, to list any symbolic links to `sysdep.c' in the
  316.      current directory and its subdirectories, you can do:
  317.           find . -lname '*sysdep.c'
  318.  - Option: -follow
  319.      Dereference symbolic links.  The following differences in behavior
  320.      occur when this option is given:
  321.         * `find' follows symbolic links to directories when searching
  322.           directory trees.
  323.         * `-lname' and `-ilname' always return false.
  324.         * `-type' reports the types of the files that symbolic links
  325.           point to.
  326.         * Implies `-noleaf' (*note Directories::.).
  327. File: find.info,  Node: Hard Links,  Prev: Symbolic Links,  Up: Links
  328. Hard Links
  329. ----------
  330.    To find hard links, first get the inode number of the file whose
  331. links you want to find.  You can learn a file's inode number and the
  332. number of links to it by running `ls -i' or `find -ls'.  If the file has
  333. more than one link, you can search for the other links by passing that
  334. inode number to `-inum'.  Add the `-xdev' option if you are starting
  335. the search at a directory that has other filesystems mounted on it,
  336. such as `/usr' on many systems.  Doing this saves needless searching,
  337. since hard links to a file must be on the same filesystem.  *Note
  338. Filesystems::.
  339.  - Test: -inum N
  340.      File has inode number N.
  341.    You can also search for files that have a certain number of links,
  342. with `-links'.  Directories normally have at least two hard links; their
  343. `.' entry is the second one.  If they have subdirectories, each of
  344. those also has a hard link called `..' to its parent directory.
  345.  - Test: -links N
  346.      File has N hard links.
  347. File: find.info,  Node: Time,  Next: Size,  Prev: Links,  Up: Finding Files
  348.    Each file has three time stamps, which record the last time that
  349. certain operations were performed on the file:
  350.   1. access (read the file's contents)
  351.   2. change the status (modify the file or its attributes)
  352.   3. modify (change the file's contents)
  353.    You can search for files whose time stamps are within a certain age
  354. range, or compare them to other time stamps.
  355. * Menu:
  356. * Age Ranges::
  357. * Comparing Timestamps::
  358. File: find.info,  Node: Age Ranges,  Next: Comparing Timestamps,  Up: Time
  359. Age Ranges
  360. ----------
  361.    These tests are mainly useful with ranges (`+N' and `-N').
  362.  - Test: -atime N
  363.  - Test: -ctime N
  364.  - Test: -mtime N
  365.      True if the file was last accessed (or its status changed, or it
  366.      was modified) N*24 hours ago.
  367.  - Test: -amin N
  368.  - Test: -cmin N
  369.  - Test: -mmin N
  370.      True if the file was last accessed (or its status changed, or it
  371.      was modified) N minutes ago.  These tests provide finer
  372.      granularity of measurement than `-atime' et al.  For example, to
  373.      list files in `/u/bill' that were last read from 2 to 6 hours ago:
  374.           find /u/bill -amin +2 -amin -6
  375.  - Option: -daystart
  376.      Measure times from the beginning of today rather than from 24
  377.      hours ago.  So, to list the regular files in your home directory
  378.      that were modified yesterday, do
  379.           find ~ -daystart -type f -mtime 1
  380. File: find.info,  Node: Comparing Timestamps,  Prev: Age Ranges,  Up: Time
  381. Comparing Timestamps
  382. --------------------
  383.    As an alternative to comparing timestamps to the current time, you
  384. can compare them to another file's timestamp.  That file's timestamp
  385. could be updated by another program when some event occurs.  Or you
  386. could set it to a particular fixed date using the `touch' command.  For
  387. example, to list files in `/usr' modified after February 1 of the
  388. current year:
  389.      touch -t 02010000 /tmp/stamp$$
  390.      find /usr -newer /tmp/stamp$$
  391.      rm -f /tmp/stamp$$
  392.  - Test: -anewer FILE
  393.  - Test: -cnewer FILE
  394.  - Test: -newer FILE
  395.      True if the file was last accessed (or its status changed, or it
  396.      was modified) more recently than FILE was modified.  These tests
  397.      are affected by `-follow' only if `-follow' comes before them on
  398.      the command line.  *Note Symbolic Links::, for more information on
  399.      `-follow'.  As an example, to list any files modified since
  400.      `/bin/sh' was last modified:
  401.           find . -newer /bin/sh
  402.  - Test: -used N
  403.      True if the file was last accessed N days after its status was
  404.      last changed.  Useful for finding files that are not being used,
  405.      and could perhaps be archived or removed to save disk space.
  406. File: find.info,  Node: Size,  Next: Type,  Prev: Time,  Up: Finding Files
  407.  - Test: -size N[BCKW]
  408.      True if the file uses N units of space, rounding up.  The units
  409.      are 512-byte blocks by default, but they can be changed by adding a
  410.      one-character suffix to N:
  411.     `b'
  412.           512-byte blocks
  413.     `c'
  414.           bytes
  415.     `k'
  416.           kilobytes (1024 bytes)
  417.     `w'
  418.           2-byte words
  419.      The size does not count indirect blocks, but it does count blocks
  420.      in sparse files that are not actually allocated.
  421.  - Test: -empty
  422.      True if the file is empty and is either a regular file or a
  423.      directory.  This might make it a good candidate for deletion.
  424.      This test is useful with `-depth' (*note Directories::.) and
  425.      `-exec rm -rf '{}' ';'' (*note Single File::.).
  426. File: find.info,  Node: Type,  Next: Owner,  Prev: Size,  Up: Finding Files
  427.  - Test: -type C
  428.      True if the file is of type C:
  429.     `b'
  430.           block (buffered) special
  431.     `c'
  432.           character (unbuffered) special
  433.     `d'
  434.           directory
  435.     `p'
  436.           named pipe (FIFO)
  437.     `f'
  438.           regular file
  439.     `l'
  440.           symbolic link
  441.     `s'
  442.           socket
  443.  - Test: -xtype C
  444.      The same as `-type' unless the file is a symbolic link.  For
  445.      symbolic links: if `-follow' has not been given, true if the file
  446.      is a link to a file of type C; if `-follow' has been given, true
  447.      if C is `l'.  In other words, for symbolic links, `-xtype' checks
  448.      the type of the file that `-type' does not check.  *Note Symbolic
  449.      Links::, for more information on `-follow'.
  450. File: find.info,  Node: Owner,  Next: Permissions,  Prev: Type,  Up: Finding Files
  451. Owner
  452. =====
  453.  - Test: -user UNAME
  454.  - Test: -group GNAME
  455.      True if the file is owned by user UNAME (belongs to group GNAME).
  456.      A numeric ID is allowed.
  457.  - Test: -uid N
  458.  - Test: -gid N
  459.      True if the file's numeric user ID (group ID) is N.  These tests
  460.      support ranges (`+N' and `-N'), unlike `-user' and `-group'.
  461.  - Test: -nouser
  462.  - Test: -nogroup
  463.      True if no user corresponds to the file's numeric user ID (no group
  464.      corresponds to the numeric group ID).  These cases usually mean
  465.      that the files belonged to users who have since been removed from
  466.      the system.  You probably should change the ownership of such
  467.      files to an existing user or group, using the `chown' or `chgrp'
  468.      program.
  469. File: find.info,  Node: Permissions,  Next: Contents,  Prev: Owner,  Up: Finding Files
  470. Permissions
  471. ===========
  472.    *Note File Permissions::, for information on how file permissions are
  473. structured and how to specify them.
  474.  - Test: -perm MODE
  475.      True if the file's permissions are exactly MODE (which can be
  476.      numeric or symbolic).  Symbolic modes use mode 0 as a point of
  477.      departure.  If MODE starts with `-', true if *all* of the
  478.      permissions set in MODE are set for the file; permissions not set
  479.      in MODE are ignored.  If MODE starts with `+', true if *any* of
  480.      the permissions set in MODE are set for the file; permissions not
  481.      set in MODE are ignored.
  482. File: find.info,  Node: Contents,  Next: Directories,  Prev: Permissions,  Up: Finding Files
  483. Contents
  484. ========
  485.    To search for files based on their contents, you can use the `grep'
  486. program.  For example, to find out which C source files in the current
  487. directory contain the string `thing', you can do:
  488.      grep -l thing *.[ch]
  489.    If you also want to search for the string in files in subdirectories,
  490. you can combine `grep' with `find' and `xargs', like this:
  491.      find . -name '*.[ch]' | xargs grep -l thing
  492.    The `-l' option causes `grep' to print only the names of files that
  493. contain the string, rather than the lines that contain it.  The string
  494. argument (`thing') is actually a regular expression, so it can contain
  495. metacharacters.  This method can be refined a little by using the `-r'
  496. option to make `xargs' not run `grep' if `find' produces no output, and
  497. using the `find' action `-print0' and the `xargs' option `-0' to avoid
  498. misinterpreting files whose names contain spaces:
  499.      find . -name '*.[ch]' -print0 | xargs -r -0 grep -l thing
  500.    For a fuller treatment of finding files whose contents match a
  501. pattern, see the manual page for `grep'.
  502. File: find.info,  Node: Directories,  Next: Filesystems,  Prev: Contents,  Up: Finding Files
  503. Directories
  504. ===========
  505.    Here is how to control which directories `find' searches, and how it
  506. searches them.  These two options allow you to process a horizontal
  507. slice of a directory tree.
  508.  - Option: -maxdepth LEVELS
  509.      Descend at most LEVELS (a non-negative integer) levels of
  510.      directories below the command line arguments.  `-maxdepth 0' means
  511.      only apply the tests and actions to the command line arguments.
  512.  - Option: -mindepth LEVELS
  513.      Do not apply any tests or actions at levels less than LEVELS (a
  514.      non-negative integer).  `-mindepth 1' means process all files
  515.      except the command line arguments.
  516.  - Option: -depth
  517.      Process each directory's contents before the directory itself.
  518.      Doing this is a good idea when producing lists of files to archive
  519.      with `cpio' or `tar'.  If a directory does not have write
  520.      permission for its owner, its contents can still be restored from
  521.      the archive since the directory's permissions are restored after
  522.      its contents.
  523.  - Action: -prune
  524.      If `-depth' is not given, true; do not descend the current
  525.      directory.  If `-depth' is given, false; no effect.  `-prune' only
  526.      affects tests and actions that come after it in the expression, not
  527.      those that come before.
  528.      For example, to skip the directory `src/emacs' and all files and
  529.      directories under it, and print the names of the other files found:
  530.           find . -path './src/emacs' -prune -o -print
  531.  - Option: -noleaf
  532.      Do not optimize by assuming that directories contain 2 fewer
  533.      subdirectories than their hard link count.  This option is needed
  534.      when searching filesystems that do not follow the Unix
  535.      directory-link convention, such as CD-ROM or MS-DOS filesystems or
  536.      AFS volume mount points.  Each directory on a normal Unix
  537.      filesystem has at least 2 hard links: its name and its `.'  entry.
  538.      Additionally, its subdirectories (if any) each have a `..'  entry
  539.      linked to that directory.  When `find' is examining a directory,
  540.      after it has statted 2 fewer subdirectories than the directory's
  541.      link count, it knows that the rest of the entries in the directory
  542.      are non-directories ("leaf" files in the directory tree).  If only
  543.      the files' names need to be examined, there is no need to stat
  544.      them; this gives a significant increase in search speed.
  545. File: find.info,  Node: Filesystems,  Next: Combining Primaries With Operators,  Prev: Directories,  Up: Finding Files
  546. Filesystems
  547. ===========
  548.    A "filesystem" is a section of a disk, either on the local host or
  549. mounted from a remote host over a network.  Searching network
  550. filesystems can be slow, so it is common to make `find' avoid them.
  551.    There are two ways to avoid searching certain filesystems.  One way
  552. is to tell `find' to only search one filesystem:
  553.  - Option: -xdev
  554.  - Option: -mount
  555.      Don't descend directories on other filesystems.  These options are
  556.      synonyms.
  557.    The other way is to check the type of filesystem each file is on, and
  558. not descend directories that are on undesirable filesystem types:
  559.  - Test: -fstype TYPE
  560.      True if the file is on a filesystem of type TYPE.  The valid
  561.      filesystem types vary among different versions of Unix; an
  562.      incomplete list of filesystem types that are accepted on some
  563.      version of Unix or another is:
  564.           ufs 4.2 4.3 nfs tmp mfs S51K S52K
  565.      You can use `-printf' with the `%F' directive to see the types of
  566.      your filesystems.  *Note Print File Information::.  `-fstype' is
  567.      usually used with `-prune' to avoid searching remote filesystems
  568.      (*note Directories::.).
  569. File: find.info,  Node: Combining Primaries With Operators,  Prev: Filesystems,  Up: Finding Files
  570. Combining Primaries With Operators
  571. ==================================
  572.    Operators build a complex expression from tests and actions.  The
  573. operators are, in order of decreasing precedence:
  574. `( EXPR )'
  575.      Force precedence.  True if EXPR is true.
  576. `! EXPR'
  577. `-not EXPR'
  578.      True if EXPR is false.
  579. `EXPR1 EXPR2'
  580. `EXPR1 -a EXPR2'
  581. `EXPR1 -and EXPR2'
  582.      And; EXPR2 is not evaluated if EXPR1 is false.
  583. `EXPR1 -o EXPR2'
  584. `EXPR1 -or EXPR2'
  585.      Or; EXPR2 is not evaluated if EXPR1 is true.
  586. `EXPR1 , EXPR2'
  587.      List; both EXPR1 and EXPR2 are always evaluated.  True if EXPR2 is
  588.      true.  The value of EXPR1 is discarded.  This operator lets you do
  589.      multiple independent operations on one traversal, without
  590.      depending on whether other operations succeeded.
  591.    `find' searches the directory tree rooted at each file name by
  592. evaluating the expression from left to right, according to the rules of
  593. precedence, until the outcome is known (the left hand side is false for
  594. `-and', true for `-or'), at which point `find' moves on to the next
  595. file name.
  596.    There are two other tests that can be useful in complex expressions:
  597.  - Test: -true
  598.      Always true.
  599.  - Test: -false
  600.      Always false.
  601. File: find.info,  Node: Actions,  Next: Common Tasks,  Prev: Finding Files,  Up: Top
  602. Actions
  603. *******
  604.    There are several ways you can print information about the files that
  605. match the criteria you gave in the `find' expression.  You can print
  606. the information either to the standard output or to a file that you
  607. name.  You can also execute commands that have the file names as
  608. arguments.  You can use those commands as further filters to select
  609. files.
  610. * Menu:
  611. * Print File Name::
  612. * Print File Information::
  613. * Run Commands::
  614. * Adding Tests::
  615. File: find.info,  Node: Print File Name,  Next: Print File Information,  Up: Actions
  616. Print File Name
  617. ===============
  618.  - Action: -print
  619.      True; print the full file name on the standard output, followed by
  620.      a newline.
  621.  - Action: -fprint FILE
  622.      True; print the full file name into file FILE, followed by a
  623.      newline.  If FILE does not exist when `find' is run, it is
  624.      created; if it does exist, it is truncated to 0 bytes.  The file
  625.      names `/dev/stdout' and `/dev/stderr' are handled specially; they
  626.      refer to the standard output and standard error output,
  627.      respectively.
  628. File: find.info,  Node: Print File Information,  Next: Run Commands,  Prev: Print File Name,  Up: Actions
  629. Print File Information
  630. ======================
  631.  - Action: -ls
  632.      True; list the current file in `ls -dils' format on the standard
  633.      output.  The output looks like this:
  634.           204744   17 -rw-r--r--   1 djm      staff       17337 Nov  2  1992 ./lwall-quotes
  635.      The fields are:
  636.        1. The inode number of the file.  *Note Hard Links::, for how to
  637.           find files based on their inode number.
  638.        2. the number of blocks in the file.  The block counts are of 1K
  639.           blocks, unless the environment variable `POSIXLY_CORRECT' is
  640.           set, in which case 512-byte blocks are used.  *Note Size::,
  641.           for how to find files based on their size.
  642.        3. The file's type and permissions.  The type is shown as a dash
  643.           for a regular file; for other file types, a letter like for
  644.           `-type' is used (*note Type::.).  The permissions are read,
  645.           write, and execute for the file's owner, its group, and other
  646.           users, respectively; a dash means the permission is not
  647.           granted.  *Note File Permissions::, for more details about
  648.           file permissions.  *Note Permissions::, for how to find files
  649.           based on their permissions.
  650.        4. The number of hard links to the file.
  651.        5. The user who owns the file.
  652.        6. The file's group.
  653.        7. The file's size in bytes.
  654.        8. The date the file was last modified.
  655.        9. The file's name.  `-ls' quotes non-printable characters in
  656.           the file names using C-like backslash escapes.
  657.  - Action: -fls FILE
  658.      True; like `-ls' but write to FILE like `-fprint' (*note Print
  659.      File Name::.).
  660.  - Action: -printf FORMAT
  661.      True; print FORMAT on the standard output, interpreting `\'
  662.      escapes and `%' directives.  Field widths and precisions can be
  663.      specified as with the `printf' C function.  Unlike `-print',
  664.      `-printf' does not add a newline at the end of the string.
  665.  - Action: -fprintf FILE FORMAT
  666.      True; like `-printf' but write to FILE like `-fprint' (*note Print
  667.      File Name::.).
  668. * Menu:
  669. * Escapes::
  670. * Format Directives::
  671. * Time Formats::
  672. File: find.info,  Node: Escapes,  Next: Format Directives,  Up: Print File Information
  673. Escapes
  674. -------
  675.    The escapes that `-printf' and `-fprintf' recognize are:
  676.      Alarm bell.
  677.      Backspace.
  678.      Stop printing from this format immediately and flush the output.
  679.      Form feed.
  680.      Newline.
  681.      Carriage return.
  682.      Horizontal tab.
  683.      Vertical tab.
  684.      A literal backslash (`\').
  685.    A `\' character followed by any other character is treated as an
  686. ordinary character, so they both are printed, and a warning message is
  687. printed to the standard error output (because it was probably a typo).
  688. File: find.info,  Node: Format Directives,  Next: Time Formats,  Prev: Escapes,  Up: Print File Information
  689. Format Directives
  690. -----------------
  691.    `-printf' and `-fprintf' support the following format directives to
  692. print information about the file being processed.  Unlike the C
  693. `printf' function, they do not support field width specifiers.
  694.    `%%' is a literal percent sign.  A `%' character followed by any
  695. other character is discarded (but the other character is printed), and
  696. a warning message is printed to the standard error output (because it
  697. was probably a typo).
  698. * Menu:
  699. * Name Directives::
  700. * Ownership Directives::
  701. * Size Directives::
  702. * Location Directives::
  703. * Time Directives::
  704. File: find.info,  Node: Name Directives,  Next: Ownership Directives,  Up: Format Directives
  705. Name Directives
  706. ...............
  707.      File's name.
  708.      File's name with any leading directories removed (only the last
  709.      element).
  710.      Leading directories of file's name (all but the last element and
  711.      the slash before it).
  712.      File's name with the name of the command line argument under which
  713.      it was found removed from the beginning.
  714.      Command line argument under which file was found.
  715. File: find.info,  Node: Ownership Directives,  Next: Size Directives,  Prev: Name Directives,  Up: Format Directives
  716. Ownership Directives
  717. ....................
  718.      File's group name, or numeric group ID if the group has no name.
  719.      File's numeric group ID.
  720.      File's user name, or numeric user ID if the user has no name.
  721.      File's numeric user ID.
  722.      File's permissions (in octal).
  723. File: find.info,  Node: Size Directives,  Next: Location Directives,  Prev: Ownership Directives,  Up: Format Directives
  724. Size Directives
  725. ...............
  726.      File's size in 1K blocks (rounded up).
  727.      File's size in 512-byte blocks (rounded up).
  728.      File's size in bytes.
  729. File: find.info,  Node: Location Directives,  Next: Time Directives,  Prev: Size Directives,  Up: Format Directives
  730. Location Directives
  731. ...................
  732.      File's depth in the directory tree; files named on the command line
  733.      have a depth of 0.
  734.      Type of the filesystem the file is on; this value can be used for
  735.      `-fstype' (*note Directories::.).
  736.      Object of symbolic link (empty string if file is not a symbolic
  737.      link).
  738.      File's inode number (in decimal).
  739.      Number of hard links to file.
  740. File: find.info,  Node: Time Directives,  Prev: Location Directives,  Up: Format Directives
  741. Time Directives
  742. ...............
  743.    Some of these directives use the C `ctime' function.  Its output
  744. depends on the current locale, but it typically looks like
  745.      Wed Nov  2 00:42:36 1994
  746.      File's last access time in the format returned by the C `ctime'
  747.      function.
  748. `%AK'
  749.      File's last access time in the format specified by K (*note Time
  750.      Formats::.).
  751.      File's last status change time in the format returned by the C
  752.      `ctime' function.
  753. `%CK'
  754.      File's last status change time in the format specified by K (*note
  755.      Time Formats::.).
  756.      File's last modification time in the format returned by the C
  757.      `ctime' function.
  758. `%TK'
  759.      File's last modification time in the format specified by K (*note
  760.      Time Formats::.).
  761. File: find.info,  Node: Time Formats,  Prev: Format Directives,  Up: Print File Information
  762. Time Formats
  763. ------------
  764.    Below are the formats for the directives `%A', `%C', and `%T', which
  765. print the file's timestamps.  Some of these formats might not be
  766. available on all systems, due to differences in the C `strftime'
  767. function between systems.
  768. * Menu:
  769. * Time Components::
  770. * Date Components::
  771. * Combined Time Formats::
  772. File: find.info,  Node: Time Components,  Next: Date Components,  Up: Time Formats
  773. Time Components
  774. ...............
  775.    The following format directives print single components of the time.
  776.      hour (00..23)
  777.      hour (01..12)
  778.      hour ( 0..23)
  779.      hour ( 1..12)
  780.      locale's AM or PM
  781.      time zone (e.g., EDT), or nothing if no time zone is determinable
  782.      minute (00..59)
  783.      second (00..61)
  784.      seconds since Jan. 1, 1970, 00:00 GMT.
  785. File: find.info,  Node: Date Components,  Next: Combined Time Formats,  Prev: Time Components,  Up: Time Formats
  786. Date Components
  787. ...............
  788.    The following format directives print single components of the date.
  789.      locale's abbreviated weekday name (Sun..Sat)
  790.      locale's full weekday name, variable length (Sunday..Saturday)
  791.      locale's abbreviated month name (Jan..Dec)
  792.      locale's full month name, variable length (January..December)
  793.      month (01..12)
  794.      day of month (01..31)
  795.      day of week (0..6)
  796.      day of year (001..366)
  797.      week number of year with Sunday as first day of week (00..53)
  798.      week number of year with Monday as first day of week (00..53)
  799.      year (1970...)
  800.      last two digits of year (00..99)
  801. File: find.info,  Node: Combined Time Formats,  Prev: Date Components,  Up: Time Formats
  802. Combined Time Formats
  803. .....................
  804.    The following format directives print combinations of time and date
  805. components.
  806.      time, 12-hour (hh:mm:ss [AP]M)
  807.      time, 24-hour (hh:mm:ss)
  808.      locale's time representation (H:M:S)
  809.      locale's date and time (Sat Nov 04 12:02:33 EST 1989)
  810.      date (mm/dd/yy)
  811.      locale's date representation (mm/dd/yy)
  812. File: find.info,  Node: Run Commands,  Next: Adding Tests,  Prev: Print File Information,  Up: Actions
  813. Run Commands
  814. ============
  815.    You can use the list of file names created by `find' or `locate' as
  816. arguments to other commands.  In this way you can perform arbitrary
  817. actions on the files.
  818. * Menu:
  819. * Single File::
  820. * Multiple Files::
  821. * Querying::
  822. File: find.info,  Node: Single File,  Next: Multiple Files,  Up: Run Commands
  823. Single File
  824. -----------
  825.    Here is how to run a command on one file at a time.
  826.  - Action: -exec COMMAND ;
  827.      Execute COMMAND; true if 0 status is returned.  `find' takes all
  828.      arguments after `-exec' to be part of the command until an
  829.      argument consisting of `;' is reached.  It replaces the string
  830.      `{}' by the current file name being processed everywhere it occurs
  831.      in the command.  Both of these constructions need to be escaped
  832.      (with a `\') or quoted to protect them from expansion by the shell.
  833.      The command is executed in the directory in which `find' was run.
  834.      For example, to compare each C header file in the current
  835.      directory with the file `/tmp/master':
  836.           find . -name '*.h' -exec diff -u '{}' /tmp/master ';'
  837. File: find.info,  Node: Multiple Files,  Next: Querying,  Prev: Single File,  Up: Run Commands
  838. Multiple Files
  839. --------------
  840.    Sometimes you need to process files alone.  But when you don't, it
  841. is faster to run a command on as many files as possible at a time,
  842. rather than once per file.  Doing this saves on the time it takes to
  843. start up the command each time.
  844.    To run a command on more than one file at once, use the `xargs'
  845. command, which is invoked like this:
  846.      xargs [OPTION...] [COMMAND [INITIAL-ARGUMENTS]]
  847.    `xargs' reads arguments from the standard input, delimited by blanks
  848. (which can be protected with double or single quotes or a backslash) or
  849. newlines.  It executes the COMMAND (default is `/bin/echo') one or more
  850. times with any INITIAL-ARGUMENTS followed by arguments read from
  851. standard input.  Blank lines on the standard input are ignored.
  852.    Instead of blank-delimited names, it is safer to use `find -print0'
  853. or `find -fprint0' and process the output by giving the `-0' or
  854. `--null' option to GNU `xargs', GNU `tar', GNU `cpio', or `perl'.
  855.    You can use shell command substitution (backquotes) to process a
  856. list of arguments, like this:
  857.      grep -l sprintf `find $HOME -name '*.c' -print`
  858.    However, that method produces an error if the length of the `.c'
  859. file names exceeds the operating system's command-line length limit.
  860. `xargs' avoids that problem by running the command as many times as
  861. necessary without exceeding the limit:
  862.      find $HOME -name '*.c' -print | grep -l sprintf
  863.    However, if the command needs to have its standard input be a
  864. terminal (`less', for example), you have to use the shell command
  865. substitution method.
  866. * Menu:
  867. * Unsafe File Name Handling::
  868. * Safe File Name Handling::
  869. * Limiting Command Size::
  870. * Interspersing File Names::
  871. File: find.info,  Node: Unsafe File Name Handling,  Next: Safe File Name Handling,  Up: Multiple Files
  872. Unsafe File Name Handling
  873. .........................
  874.    Because file names can contain quotes, backslashes, blank characters,
  875. and even newlines, it is not safe to process them using `xargs' in its
  876. default mode of operation.  But since most files' names do not contain
  877. blanks, this problem occurs only infrequently.  If you are only
  878. searching through files that you know have safe names, then you need not
  879. be concerned about it.
  880.    In many applications, if `xargs' botches processing a file because
  881. its name contains special characters, some data might be lost.  The
  882. importance of this problem depends on the importance of the data and
  883. whether anyone notices the loss soon enough to correct it.  However,
  884. here is an extreme example of the problems that using blank-delimited
  885. names can cause.  If the following command is run daily from `cron',
  886. then any user can remove any file on the system:
  887.      find / -name '#*' -atime +7 -print | xargs rm
  888.    For example, you could do something like this:
  889.      eg$ echo > '#
  890.      vmunix'
  891. and then `cron' would delete `/vmunix', if it ran `xargs' with `/' as
  892. its current directory.
  893.    To delete other files, for example `/u/joeuser/.plan', you could do
  894. this:
  895.      eg$ mkdir '#
  896.      '
  897.      eg$ cd '#
  898.      '
  899.      eg$ mkdir u u/joeuser u/joeuser/.plan'
  900.      '
  901.      eg$ echo > u/joeuser/.plan'
  902.      /#foo'
  903.      eg$ cd ..
  904.      eg$ find . -name '#*' -print | xargs echo
  905.      ./# ./# /u/joeuser/.plan /#foo
  906. File: find.info,  Node: Safe File Name Handling,  Next: Limiting Command Size,  Prev: Unsafe File Name Handling,  Up: Multiple Files
  907. Safe File Name Handling
  908. .......................
  909.    Here is how to make `find' output file names so that they can be
  910. used by other programs without being mangled or misinterpreted.  You can
  911. process file names generated this way by giving the `-0' or `--null'
  912. option to GNU `xargs', GNU `tar', GNU `cpio', or `perl'.
  913.  - Action: -print0
  914.      True; print the full file name on the standard output, followed by
  915.      a null character.
  916.  - Action: -fprint0 FILE
  917.      True; like `-print0' but write to FILE like `-fprint' (*note Print
  918.      File Name::.).
  919. File: find.info,  Node: Limiting Command Size,  Next: Interspersing File Names,  Prev: Safe File Name Handling,  Up: Multiple Files
  920. Limiting Command Size
  921. .....................
  922.    `xargs' gives you control over how many arguments it passes to the
  923. command each time it executes it.  By default, it uses up to `ARG_MAX'
  924. - 2k, or 20k, whichever is smaller, characters per command.  It uses as
  925. many lines and arguments as fit within that limit.  The following
  926. options modify those values.
  927. `--no-run-if-empty'
  928.      If the standard input does not contain any nonblanks, do not run
  929.      the command.  By default, the command is run once even if there is
  930.      no input.
  931. `--max-lines[=MAX-LINES]'
  932. `-l[MAX-LINES]'
  933.      Use at most MAX-LINES nonblank input lines per command line;
  934.      MAX-LINES defaults to 1 if omitted.  Trailing blanks cause an
  935.      input line to be logically continued on the next input line, for
  936.      the purpose of counting the lines.  Implies `-x'.
  937. `--max-args=MAX-ARGS'
  938. `-n MAX-ARGS'
  939.      Use at most MAX-ARGS arguments per command line.  Fewer than
  940.      MAX-ARGS arguments will be used if the size (see the `-s' option)
  941.      is exceeded, unless the `-x' option is given, in which case
  942.      `xargs' will exit.
  943. `--max-chars=MAX-CHARS'
  944. `-s MAX-CHARS'
  945.      Use at most MAX-CHARS characters per command line, including the
  946.      command and initial arguments and the terminating nulls at the
  947.      ends of the argument strings.
  948. `--max-procs=MAX-PROCS'
  949. `-P MAX-PROCS'
  950.      Run up to MAX-PROCS processes at a time; the default is 1.  If
  951.      MAX-PROCS is 0, `xargs' will run as many processes as possible at
  952.      a time.  Use the `-n', `-s', or `-l' option with `-P'; otherwise
  953.      chances are that the command will be run only once.
  954. File: find.info,  Node: Interspersing File Names,  Prev: Limiting Command Size,  Up: Multiple Files
  955. Interspersing File Names
  956. ........................
  957.    `xargs' can insert the name of the file it is processing between
  958. arguments you give for the command.  Unless you also give options to
  959. limit the command size (*note Limiting Command Size::.), this mode of
  960. operation is equivalent to `find -exec' (*note Single File::.).
  961. `--replace[=REPLACE-STR]'
  962. `-i[REPLACE-STR]'
  963.      Replace occurences of REPLACE-STR in the initial arguments with
  964.      names read from standard input.  Also, unquoted blanks do not
  965.      terminate arguments.  If REPLACE-STR is omitted, it defaults to
  966.      `{}' (like for `find -exec').  Implies `-x' and `-l 1'.  As an
  967.      example, to sort each file the `bills' directory, leaving the
  968.      output in that file name with `.sorted' appended, you could do:
  969.           find bills -type f | xargs -iXX sort -o XX.sorted XX
  970.      The equivalent command using `find -exec' is:
  971.           find bills -type f -exec sort -o '{}.sorted' '{}' ';'
  972. File: find.info,  Node: Querying,  Prev: Multiple Files,  Up: Run Commands
  973. Querying
  974. --------
  975.    To ask the user whether to execute a command on a single file, you
  976. can use the `find' primary `-ok' instead of `-exec':
  977.  - Action: -ok COMMAND ;
  978.      Like `-exec' (*note Single File::.), but ask the user first (on
  979.      the standard input); if the response does not start with `y' or
  980.      `Y', do not run the command, and return false.
  981.    When processing multiple files with a single command, to query the
  982. user you give `xargs' the following option.  When using this option, you
  983. might find it useful to control the number of files processed per
  984. invocation of the command (*note Limiting Command Size::.).
  985. `--interactive'
  986.      Prompt the user about whether to run each command line and read a
  987.      line from the terminal.  Only run the command line if the response
  988.      starts with `y' or `Y'.  Implies `-t'.
  989. File: find.info,  Node: Adding Tests,  Prev: Run Commands,  Up: Actions
  990. Adding Tests
  991. ============
  992.    You can test for file attributes that none of the `find' builtin
  993. tests check.  To do this, use `xargs' to run a program that filters a
  994. list of files printed by `find'.  If possible, use `find' builtin tests
  995. to pare down the list, so the program run by `xargs' has less work to
  996. do.  The tests builtin to `find' will likely run faster than tests that
  997. other programs perform.
  998.    For example, here is a way to print the names of all of the
  999. unstripped binaries in the `/usr/local' directory tree.  Builtin tests
  1000. avoid running `file' on files that are not regular files or are not
  1001. executable.
  1002.      find /usr/local -type f -perm +a=x | xargs file |
  1003.        grep 'not stripped' | cut -d: -f1
  1004. The `cut' program removes everything after the file name from the
  1005. output of `file'.
  1006.    If you want to place a special test somewhere in the middle of a
  1007. `find' expression, you can use `-exec' to run a program that performs
  1008. the test.  Because `-exec' evaluates to the exit status of the executed
  1009. program, you can write a program (which can be a shell script) that
  1010. tests for a special attribute and make it exit with a true (zero) or
  1011. false (non-zero) status.  It is a good idea to place such a special
  1012. test *after* the builtin tests, because it starts a new process which
  1013. could be avoided if a builtin test evaluates to false.  Use this method
  1014. only when `xargs' is not flexible enough, because starting one or more
  1015. new processes to test each file is slower than using `xargs' to start
  1016. one process that tests many files.
  1017.    Here is a shell script called `unstripped' that checks whether its
  1018. argument is an unstripped binary file:
  1019.      #!/bin/sh
  1020.      file $1 | grep 'not stripped' > /dev/null
  1021.    This script relies on the fact that the shell exits with the status
  1022. of the last program it executed, in this case `grep'.  `grep' exits
  1023. with a true status if it found any matches, false if not.  Here is an
  1024. example of using the script (assuming it is in your search path).  It
  1025. lists the stripped executables in the file `sbins' and the unstripped
  1026. ones in `ubins'.
  1027.      find /usr/local -type f -perm +a=x \
  1028.        \( -exec unstripped '{}' \; -fprint ubins -o -fprint sbins \)
  1029. File: find.info,  Node: Common Tasks,  Next: Databases,  Prev: Actions,  Up: Top
  1030. Common Tasks
  1031. ************
  1032.    The sections that follow contain some extended examples that both
  1033. give a good idea of the power of these programs, and show you how to
  1034. solve common real-world problems.
  1035. * Menu:
  1036. * Viewing And Editing::
  1037. * Archiving::
  1038. * Cleaning Up::
  1039. * Strange File Names::
  1040. * Fixing Permissions::
  1041. * Classifying Files::
  1042.