home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / info / find.info-1 (.txt) < prev    next >
GNU Info File  |  1994-12-22  |  51KB  |  1,042 lines

  1. This is Info file find.info, produced by Makeinfo-1.55 from the input
  2. file 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.