home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / textprocess / grep_2 / release / Resources / Manual < prev    next >
Text File  |  1989-03-12  |  7KB  |  158 lines

  1. GREP 1 "1988 December 13" "GNU Project"
  2.  
  3. NAME
  4. grep, egrep - print lines matching a regular expression
  5.  
  6. SYNOPSIS
  7. grep [-CVbchilnsvwx] [- num] [-AB num] [ [-e] expr|-f file] ] ["files ..."]
  8.  
  9. DESCRIPTION
  10. Grep searches the files listed in the arguments (or standard
  11. input if no files are given) for all lines that contain a match for
  12. the given expr .
  13. If any lines match, they are printed.
  14. Also, if any matches were found, grep will exit with a status of 0, but if no 
  15. matches were found it will exit with a status of 1.  This is useful for
  16. building shell scripts that use grep as a condition for, for example, the
  17. if statement.
  18.  
  19. When invoked as egrep the syntax of the expr is slightly different; See below.
  20.  
  21. REGULAR EXPRESSIONS
  22. (grep)  (egrep)         (explanation)
  23.   c        c            a single (non-meta) character matches itself.
  24.   .        .            matches any single character except newline.
  25.   ?        ?            postfix operator; preceeding item is optional.
  26.   *        *            postfix operator; preceeding item 0 or more times.
  27.   +        +            postfix operator; preceeding item 1 or more times.
  28.   |        |            infix operator; matches either argument.
  29.   ^        ^            matches the empty string at the beginning of a line.
  30.   $        $            matches the empty string at the end of a line.
  31.   <        <            matches the empty string at the beginning of a word.
  32.   >        >            matches the empty string at the end of a word.
  33.   [chars]  [chars]      match any character in the given class; if the
  34.                         first character after [ is ^, match any character
  35.                         not in the given class; a range of characters may
  36.                         be specified by first-last; for example, W                                      (below) is equivalent to the class [^A\-Za\-z0\-9]
  37. ( )        ( )          parentheses are used to override operator precedence.
  38. digit      digit        n matches a repeat of the text matched earlier in the
  39.                         regexp by the subexpression inside the nth
  40.                         opening parenthesis.
  41.   \          \          any special character may be preceded by a backslash
  42.                         to match it literally.
  43.  
  44. (the following are for compatibility with GNU Emacs)
  45.   \b         \b         matches the empty string at the edge of a word.
  46.   \B         \B         matches the empty string if not at the edge of a word.
  47.   \w         \w         matches word-constituent characters (letters & digits).
  48.   \W         \W         matches characters that are not word-constituent.
  49.  
  50.  
  51. Operator precedence is (highest to lowest) ?, (*, and +, concatenation,
  52. and finally |.  All other constructs are syntactically identical to
  53. normal characters.  For the truly interested, the file dfa.c describes
  54. (and implements) the exact grammar understood by the parser.
  55.  
  56. OPTIONS
  57. -A " num"
  58. print <num> lines of context after every matching line
  59. -B " num"
  60. print num lines of context before every matching line
  61. -C
  62. print 2 lines of context on each side of every match
  63. - num
  64. print num lines of context on each side of every match
  65. -V
  66. print the version number on the diagnostic output
  67. -b
  68. print every match preceded by its byte offset
  69. -c
  70. print a total count of matching lines only
  71. -e " expr"
  72. search for expr; useful if expr begins with -
  73. -f " file"
  74. search for the expression contained in file
  75. -h
  76. don't display filenames on matches
  77. -i
  78. ignore case difference when comparing strings
  79. -l
  80. list files containing matches only
  81. -n
  82. print each match preceded by its line number
  83. -s
  84. run silently producing no output except error messages
  85. -v
  86. print only lines that contain no matches for the <expr>
  87. -w
  88. print only lines where the match is a complete word
  89. -x
  90. print only lines where the match is a whole line
  91.  
  92. SEE ALSO
  93. emacs(1), ed(1), sh(1),
  94. "GNU Emacs Manual"
  95.  
  96. INCOMPATIBILITIES
  97. The following incompatibilities with UNIX grep exist:
  98. The context-dependent meaning of (* is not quite the same (grep only).
  99. -b prints a byte offset instead of a block offset.
  100. The {m,n} construct of System V grep is not implemented.
  101.  
  102. BUGS
  103. GNU e?grep has been thoroughly debugged and tested by several people
  104. over a period of several months; we think it's a reliable beast or we
  105. wouldn't distribute it.  If by some fluke of the universe you discover
  106. a bug, send a detailed description (including options, regular
  107. expressions, and a copy of an input file that can reproduce it) to me,
  108. mike@wheaties.ai.mit.edu.
  109.  
  110. There is also a newsgroup, gnu.utils.bug, for reporting FSF utility
  111. programs' bugs and fixes; but before reporting something as a bug,
  112. please try to be sure that it really is a bug, not a misunderstanding
  113. or a deliberate feature.  Also, include the version number of the
  114. utility program you are running in \fIevery\fR bug report that you
  115. send in.  Please do not send anything but bug reports to this
  116. newsgroup.
  117.  
  118. AVAILABILITY
  119. GNU grep is free; anyone may redistribute copies of grep to anyone under 
  120. the terms stated in the GNU General Public License, a copy of which may be
  121. found in each copy of GNU Emacs.
  122. See also the comment at the beginning of the source code file grep.c.
  123. Copies of GNU may sometimes be received packaged with distributions of Unix
  124. systems, but it is never included in the scope of any license covering those
  125. systems.  Such inclusion violates the terms on which distribution
  126. is permitted.  In fact, the primary purpose of the General Public
  127. License is to prohibit anyone from attaching any other restrictions
  128. to redistribution of any of the Free Software Foundation programs.
  129.  
  130.  
  131. AUTHORS
  132. Mike Haertel wrote the deterministic regexp code and the bulk
  133. of the program.
  134.  
  135. James A. Woods is responsible for the hybridized search strategy
  136. of using Boyer-Moore-Gosper fixed-string search as a filter
  137. before calling the general regexp matcher.
  138.  
  139. Arthur David Olson contributed code that finds fixed strings for
  140. the aforementioned BMG search for a large class of regexps.
  141.  
  142. Richard Stallman wrote the backtracking regexp matcher that is
  143. used for \\\fIdigit\fP backreferences, as well as the getopt that
  144. is provided for 4.2BSD sites.  The backtracking matcher was
  145. originally written for GNU Emacs.
  146.  
  147. D. A. Gwyn wrote the C alloca emulation that is provided so
  148. System V machines can run this program.  (Alloca is used only
  149. by RMS' backtracking matcher, and then only rarely, so there
  150. is no loss if your machine doesn't have a "real" alloca.)
  151.  
  152. Scott Anderson and Henry Spencer designed the regression tests
  153. used in the "regress" script.
  154.  
  155. Paul Placeway wrote the original version of this manual page.
  156.  
  157. ---------------------------------------------------------------------
  158.