home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue6 / SDL.ZIP / !gcc / docs / grep < prev    next >
Encoding:
Text File  |  2006-09-17  |  127.6 KB  |  1,918 lines

  1. <html lang="en">
  2. <head>
  3. <title>grep, print lines matching a pattern</title>
  4. <meta http-equiv="Content-Type" content="text/html">
  5. <meta name="description" content="grep, print lines matching a pattern">
  6. <meta name="generator" content="makeinfo 4.8">
  7. <link title="Top" rel="top" href="#Top">
  8. <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
  9. <meta http-equiv="Content-Style-Type" content="text/css">
  10. <style type="text/css"><!--
  11.   pre.display { font-family:inherit }
  12.   pre.format  { font-family:inherit }
  13.   pre.smalldisplay { font-family:inherit; font-size:smaller }
  14.   pre.smallformat  { font-family:inherit; font-size:smaller }
  15.   pre.smallexample { font-size:smaller }
  16.   pre.smalllisp    { font-size:smaller }
  17.   span.sc    { font-variant:small-caps }
  18.   span.roman { font-family:serif; font-weight:normal; } 
  19.   span.sansserif { font-family:sans-serif; font-weight:normal; } 
  20. --></style>
  21. </head>
  22. <body>
  23. <h1 class="settitle">grep, print lines matching a pattern</h1>
  24. <div class="node">
  25. <p><hr>
  26. <a name="Top"></a>
  27. Next: <a rel="next" accesskey="n" href="#Introduction">Introduction</a>,
  28. Up: <a rel="up" accesskey="u" href="#dir">(dir)</a>
  29.  
  30. </div>
  31.  
  32. <h2 class="unnumbered">Grep</h2>
  33.  
  34. <p><samp><span class="command">grep</span></samp> searches for lines matching a pattern.
  35.  
  36.    <p>This document was produced for version 2.5 of <span class="sc">gnu</span>
  37. <samp><span class="command">grep</span></samp>.
  38.  
  39. <ul class="menu">
  40. <li><a accesskey="1" href="#Introduction">Introduction</a>:                 Introduction. 
  41. <li><a accesskey="2" href="#Invoking">Invoking</a>:                     Invoking <samp><span class="command">grep</span></samp>; description of options. 
  42. <li><a accesskey="3" href="#Diagnostics">Diagnostics</a>:                  Exit status returned by <samp><span class="command">grep</span></samp>. 
  43. <li><a accesskey="4" href="#Grep-Programs">Grep Programs</a>:                <samp><span class="command">grep</span></samp> programs. 
  44. <li><a accesskey="5" href="#Regular-Expressions">Regular Expressions</a>:          Regular Expressions. 
  45. <li><a accesskey="6" href="#Usage">Usage</a>:                        Examples. 
  46. <li><a accesskey="7" href="#Reporting-Bugs">Reporting Bugs</a>:               Reporting Bugs. 
  47. <li><a accesskey="8" href="#Copying">Copying</a>:                      License terms. 
  48. <li><a accesskey="9" href="#Concept-Index">Concept Index</a>:                A menu with all the topics in this manual. 
  49. <li><a href="#Index">Index</a>:                        A menu with all <samp><span class="command">grep</span></samp> commands
  50.                                  and command-line options. 
  51. </ul>
  52.  
  53. <div class="node">
  54. <p><hr>
  55. <a name="Introduction"></a>
  56. Next: <a rel="next" accesskey="n" href="#Invoking">Invoking</a>,
  57. Previous: <a rel="previous" accesskey="p" href="#Top">Top</a>,
  58. Up: <a rel="up" accesskey="u" href="#Top">Top</a>
  59.  
  60. </div>
  61.  
  62. <h2 class="chapter">1 Introduction</h2>
  63.  
  64. <p><a name="index-Searching-for-a-pattern_002e-1"></a>
  65. <samp><span class="command">grep</span></samp> searches the input files
  66. for lines containing a match to a given
  67. pattern list.  When it finds a match in a line, it copies the line to standard
  68. output (by default), or does whatever other sort of output you have requested
  69. with options.
  70.  
  71.    <p>Though <samp><span class="command">grep</span></samp> expects to do the matching on text,
  72. it has no limits on input line length other than available memory,
  73. and it can match arbitrary characters within a line. 
  74. If the final byte of an input file is not a newline,
  75. <samp><span class="command">grep</span></samp> silently supplies one. 
  76. Since newline is also a separator for the list of patterns, there
  77. is no way to match newline characters in a text.
  78.  
  79. <div class="node">
  80. <p><hr>
  81. <a name="Invoking"></a>
  82. Next: <a rel="next" accesskey="n" href="#Diagnostics">Diagnostics</a>,
  83. Previous: <a rel="previous" accesskey="p" href="#Introduction">Introduction</a>,
  84. Up: <a rel="up" accesskey="u" href="#Top">Top</a>
  85.  
  86. </div>
  87.  
  88. <h2 class="chapter">2 Invoking <samp><span class="command">grep</span></samp></h2>
  89.  
  90. <p><samp><span class="command">grep</span></samp> comes with a rich set of options from <span class="sc">posix.2</span> and <span class="sc">gnu</span>
  91. extensions.
  92.  
  93.      <dl>
  94. <dt>`<samp><span class="samp">-c</span></samp>'<dt>`<samp><span class="samp">--count</span></samp>'<dd><a name="index-g_t_002dc-2"></a><a name="index-g_t_002d_002dcount-3"></a><a name="index-counting-lines-4"></a>Suppress normal output; instead print a count of matching
  95. lines for each input file.  With the `<samp><span class="samp">-v</span></samp>', `<samp><span class="samp">--invert-match</span></samp>' option,
  96. count non-matching lines.
  97.  
  98.      <br><dt>`<samp><span class="samp">-e </span><var>pattern</var></samp>'<dt>`<samp><span class="samp">--regexp=</span><var>pattern</var></samp>'<dd><a name="index-g_t_002de-5"></a><a name="index-g_t_002d_002dregexp_003d_0040var_007bpattern_007d-6"></a><a name="index-pattern-list-7"></a>Use <var>pattern</var> as the pattern; useful to protect patterns
  99. beginning with a `<samp><span class="samp">-</span></samp>'.
  100.  
  101.      <br><dt>`<samp><span class="samp">-f </span><var>file</var></samp>'<dt>`<samp><span class="samp">--file=</span><var>file</var></samp>'<dd><a name="index-g_t_002df-8"></a><a name="index-g_t_002d_002dfile-9"></a><a name="index-pattern-from-file-10"></a>Obtain patterns from <var>file</var>, one per line.  The empty
  102. file contains zero patterns, and therefore matches nothing.
  103.  
  104.      <br><dt>`<samp><span class="samp">-i</span></samp>'<dt>`<samp><span class="samp">--ignore-case</span></samp>'<dd><a name="index-g_t_002di-11"></a><a name="index-g_t_002d_002dignore_002dcase-12"></a><a name="index-case-insensitive-search-13"></a>Ignore case distinctions in both the pattern and the input files.
  105.  
  106.      <br><dt>`<samp><span class="samp">-l</span></samp>'<dt>`<samp><span class="samp">--files-with-matches</span></samp>'<dd><a name="index-g_t_002dl-14"></a><a name="index-g_t_002d_002dfiles_002dwith_002dmatches-15"></a><a name="index-names-of-matching-files-16"></a>Suppress normal output; instead print the name of each input
  107. file from which output would normally have been printed. 
  108. The scanning of every file will stop on the first match.
  109.  
  110.      <br><dt>`<samp><span class="samp">-n</span></samp>'<dt>`<samp><span class="samp">--line-number</span></samp>'<dd><a name="index-g_t_002dn-17"></a><a name="index-g_t_002d_002dline_002dnumber-18"></a><a name="index-line-numbering-19"></a>Prefix each line of output with the line number within its input file.
  111.  
  112.      <br><dt>`<samp><span class="samp">-o</span></samp>'<dt>`<samp><span class="samp">--only-matching</span></samp>'<dd><a name="index-g_t_002do-20"></a><a name="index-g_t_002d_002donly_002dmatching-21"></a><a name="index-only-matching-22"></a>Print only the part of matching lines that actually matches <var>pattern</var>.
  113.  
  114.      <br><dt>`<samp><span class="samp">-q</span></samp>'<dt>`<samp><span class="samp">--quiet</span></samp>'<dt>`<samp><span class="samp">--silent</span></samp>'<dd><a name="index-g_t_002dq-23"></a><a name="index-g_t_002d_002dquiet-24"></a><a name="index-g_t_002d_002dsilent-25"></a><a name="index-quiet_002c-silent-26"></a>Quiet; do not write anything to standard output.  Exit immediately with
  115. zero status if any match is found, even if an error was detected.  Also
  116. see the `<samp><span class="samp">-s</span></samp>' or `<samp><span class="samp">--no-messages</span></samp>' option.
  117.  
  118.      <br><dt>`<samp><span class="samp">-s</span></samp>'<dt>`<samp><span class="samp">--no-messages</span></samp>'<dd><a name="index-g_t_002ds-27"></a><a name="index-g_t_002d_002dno_002dmessages-28"></a><a name="index-suppress-error-messages-29"></a>Suppress error messages about nonexistent or unreadable files. 
  119. Portability note: unlike <span class="sc">gnu</span> <samp><span class="command">grep</span></samp>, traditional
  120. <samp><span class="command">grep</span></samp> did not conform to <span class="sc">posix.2</span>, because traditional
  121. <samp><span class="command">grep</span></samp> lacked a `<samp><span class="samp">-q</span></samp>' option and its `<samp><span class="samp">-s</span></samp>' option behaved
  122. like <span class="sc">gnu</span> <samp><span class="command">grep</span></samp>'s `<samp><span class="samp">-q</span></samp>' option.  Shell scripts intended
  123. to be portable to traditional <samp><span class="command">grep</span></samp> should avoid both
  124. `<samp><span class="samp">-q</span></samp>' and `<samp><span class="samp">-s</span></samp>' and should redirect
  125. output to <samp><span class="file">/dev/null</span></samp> instead.
  126.  
  127.      <br><dt>`<samp><span class="samp">-v</span></samp>'<dt>`<samp><span class="samp">--invert-match</span></samp>'<dd><a name="index-g_t_002dv-30"></a><a name="index-g_t_002d_002dinvert_002dmatch-31"></a><a name="index-invert-matching-32"></a><a name="index-print-non_002dmatching-lines-33"></a>Invert the sense of matching, to select non-matching lines.
  128.  
  129.      <br><dt>`<samp><span class="samp">-x</span></samp>'<dt>`<samp><span class="samp">--line-regexp</span></samp>'<dd><a name="index-g_t_002dx-34"></a><a name="index-g_t_002d_002dline_002dregexp-35"></a><a name="index-match-the-whole-line-36"></a>Select only those matches that exactly match the whole line.
  130.  
  131.    </dl>
  132.  
  133. <h3 class="section">2.1 <span class="sc">gnu</span> Extensions</h3>
  134.  
  135.      <dl>
  136. <dt>`<samp><span class="samp">-A </span><var>num</var></samp>'<dt>`<samp><span class="samp">--after-context=</span><var>num</var></samp>'<dd><a name="index-g_t_002dA-37"></a><a name="index-g_t_002d_002dafter_002dcontext-38"></a><a name="index-after-context-39"></a><a name="index-context-lines_002c-after-match-40"></a>Print <var>num</var> lines of trailing context after matching lines.
  137.  
  138.      <br><dt>`<samp><span class="samp">-B </span><var>num</var></samp>'<dt>`<samp><span class="samp">--before-context=</span><var>num</var></samp>'<dd><a name="index-g_t_002dB-41"></a><a name="index-g_t_002d_002dbefore_002dcontext-42"></a><a name="index-before-context-43"></a><a name="index-context-lines_002c-before-match-44"></a>Print <var>num</var> lines of leading context before matching lines.
  139.  
  140.      <br><dt>`<samp><span class="samp">-C </span><var>num</var></samp>'<dt>`<samp><span class="samp">--context=</span><var>num</var></samp>'<dd><a name="index-g_t_002dC-45"></a><a name="index-g_t_002d_002dcontext-46"></a><a name="index-context-47"></a>Print <var>num</var> lines of output context.
  141.  
  142.      <br><dt>`<samp><span class="samp">--colour[=</span><var>WHEN</var><span class="samp">]</span></samp>'<dt>`<samp><span class="samp">--color[=</span><var>WHEN</var><span class="samp">]</span></samp>'<dd><a name="index-g_t_002d_002dcolour-48"></a><a name="index-highlight_002c-color_002c-colour-49"></a>The matching string is surrounded by the marker specify in <var>GREP_COLOR</var>. 
  143. <var>WHEN</var> may be `never', `always', or `auto'.
  144.  
  145.      <br><dt>`<samp><span class="samp">-</span><var>num</var></samp>'<dd><a name="index-g_t_002dNUM-50"></a>Same as `<samp><span class="samp">--context=</span><var>num</var></samp>' lines of leading and trailing
  146. context.  However, grep will never print any given line more than once.
  147.  
  148.      <br><dt>`<samp><span class="samp">-V</span></samp>'<dt>`<samp><span class="samp">--version</span></samp>'<dd><a name="index-g_t_002dV-51"></a><a name="index-g_t_002d_002dversion-52"></a><a name="index-Version_002c-printing-53"></a>Print the version number of <samp><span class="command">grep</span></samp> to the standard output stream. 
  149. This version number should be included in all bug reports.
  150.  
  151.      <br><dt>`<samp><span class="samp">--help</span></samp>'<dd><a name="index-g_t_002d_002dhelp-54"></a><a name="index-Usage-summary_002c-printing-55"></a>Print a usage message briefly summarizing these command-line options
  152. and the bug-reporting address, then exit.
  153.  
  154.      <dt>`<samp><span class="samp">--binary-files=</span><var>type</var></samp>'<dd><a name="index-g_t_002d_002dbinary_002dfiles-56"></a><a name="index-binary-files-57"></a>If the first few bytes of a file indicate that the file contains binary
  155. data, assume that the file is of type <var>type</var>.  By default,
  156. <var>type</var> is `<samp><span class="samp">binary</span></samp>', and <samp><span class="command">grep</span></samp> normally outputs either
  157. a one-line message saying that a binary file matches, or no message if
  158. there is no match.  If <var>type</var> is `<samp><span class="samp">without-match</span></samp>',
  159. <samp><span class="command">grep</span></samp> assumes that a binary file does not match;
  160. this is equivalent to the `<samp><span class="samp">-I</span></samp>' option.  If <var>type</var>
  161. is `<samp><span class="samp">text</span></samp>', <samp><span class="command">grep</span></samp> processes a binary file as if it were
  162. text; this is equivalent to the `<samp><span class="samp">-a</span></samp>' option. 
  163. <em>Warning:</em> `<samp><span class="samp">--binary-files=text</span></samp>' might output binary garbage,
  164. which can have nasty side effects if the output is a terminal and if the
  165. terminal driver interprets some of it as commands.
  166.  
  167.      <br><dt>`<samp><span class="samp">-b</span></samp>'<dt>`<samp><span class="samp">--byte-offset</span></samp>'<dd><a name="index-g_t_002db-58"></a><a name="index-g_t_002d_002dbyte_002doffset-59"></a><a name="index-byte-offset-60"></a>Print the byte offset within the input file before each line of output. 
  168. When <samp><span class="command">grep</span></samp> runs on <span class="sc">ms-dos</span> or MS-Windows, the printed
  169. byte offsets
  170. depend on whether the `<samp><span class="samp">-u</span></samp>' (`<samp><span class="samp">--unix-byte-offsets</span></samp>') option is
  171. used; see below.
  172.  
  173.      <br><dt>`<samp><span class="samp">-D </span><var>action</var></samp>'<dt>`<samp><span class="samp">--devices=</span><var>action</var></samp>'<dd><a name="index-g_t_002dD-61"></a><a name="index-g_t_002d_002ddevices-62"></a><a name="index-device-search-63"></a>If an input file is a device, FIFO or socket, use <var>action</var> to process it. 
  174. By default, <var>action</var> is `<samp><span class="samp">read</span></samp>', which means that devices are
  175. read just as if they were ordinary files. 
  176. If <var>action</var> is `<samp><span class="samp">skip</span></samp>', devices, FIFOs and sockets are silently
  177. skipped.
  178.  
  179.      <br><dt>`<samp><span class="samp">-d </span><var>action</var></samp>'<dt>`<samp><span class="samp">--directories=</span><var>action</var></samp>'<dd><a name="index-g_t_002dd-64"></a><a name="index-g_t_002d_002ddirectories-65"></a><a name="index-directory-search-66"></a>If an input file is a directory, use <var>action</var> to process it. 
  180. By default, <var>action</var> is `<samp><span class="samp">read</span></samp>', which means that directories are
  181. read just as if they were ordinary files (some operating systems
  182. and filesystems disallow this, and will cause <samp><span class="command">grep</span></samp> to print error
  183. messages for every directory or silently skip them). If <var>action</var> is
  184. `<samp><span class="samp">skip</span></samp>', directories are silently skipped.  If <var>action</var> is
  185. `<samp><span class="samp">recurse</span></samp>', <samp><span class="command">grep</span></samp> reads all files under each directory,
  186. recursively; this is equivalent to the `<samp><span class="samp">-r</span></samp>' option.
  187.  
  188.      <br><dt>`<samp><span class="samp">-H</span></samp>'<dt>`<samp><span class="samp">--with-filename</span></samp>'<dd><a name="index-g_t_002dH-67"></a><a name="index-g_t_002d_002dWith_002dfilename-68"></a><a name="index-with-filename-prefix-69"></a>Print the filename for each match.
  189.  
  190.      <br><dt>`<samp><span class="samp">-h</span></samp>'<dt>`<samp><span class="samp">--no-filename</span></samp>'<dd><a name="index-g_t_002dh-70"></a><a name="index-g_t_002d_002dno_002dfilename-71"></a><a name="index-no-filename-prefix-72"></a>Suppress the prefixing of filenames on output when multiple files are searched.
  191.  
  192.      <br><dt>`<samp><span class="samp">--line-buffered</span></samp>'<dd><a name="index-g_t_002d_002dline_002dbuffered-73"></a><a name="index-line-buffering-74"></a>Set the line buffering policy, this can be a performance penality.
  193.  
  194.      <br><dt>`<samp><span class="samp">--label=</span><var>LABEL</var></samp>'<dd><a name="index-g_t_002d_002dlabel-75"></a><a name="index-changing-name-of-standard-input-76"></a>Displays input actually coming from standard input as input coming from file
  195. <var>LABEL</var>. This is especially useful for tools like zgrep, e.g. 
  196. <samp><span class="command">gzip -cd foo.gz |grep --label=foo something</span></samp>
  197.  
  198.      <br><dt>`<samp><span class="samp">-L</span></samp>'<dt>`<samp><span class="samp">--files-without-match</span></samp>'<dd><a name="index-g_t_002dL-77"></a><a name="index-g_t_002d_002dfiles_002dwithout_002dmatch-78"></a><a name="index-files-which-don_0027t-match-79"></a>Suppress normal output; instead print the name of each input
  199. file from which no output would normally have been printed. 
  200. The scanning of every file will stop on the first match.
  201.  
  202.      <br><dt>`<samp><span class="samp">-a</span></samp>'<dt>`<samp><span class="samp">--text</span></samp>'<dd><a name="index-g_t_002da-80"></a><a name="index-g_t_002d_002dtext-81"></a><a name="index-suppress-binary-data-82"></a><a name="index-binary-files-83"></a>Process a binary file as if it were text; this is equivalent to the
  203. `<samp><span class="samp">--binary-files=text</span></samp>' option.
  204.  
  205.      <br><dt>`<samp><span class="samp">-I</span></samp>'<dd>Process a binary file as if it did not contain matching data; this is
  206. equivalent to the `<samp><span class="samp">--binary-files=without-match</span></samp>' option.
  207.  
  208.      <br><dt>`<samp><span class="samp">-w</span></samp>'<dt>`<samp><span class="samp">--word-regexp</span></samp>'<dd><a name="index-g_t_002dw-84"></a><a name="index-g_t_002d_002dword_002dregexp-85"></a><a name="index-matching-whole-words-86"></a>Select only those lines containing matches that form
  209. whole words.  The test is that the matching substring
  210. must either be at the beginning of the line, or preceded
  211. by a non-word constituent character.  Similarly,
  212. it must be either at the end of the line or followed by
  213. a non-word constituent character.  Word-constituent
  214. characters are letters, digits, and the underscore.
  215.  
  216.      <br><dt>`<samp><span class="samp">-r</span></samp>'<dt>`<samp><span class="samp">-R</span></samp>'<dt>`<samp><span class="samp">--recursive</span></samp>'<dd><a name="index-g_t_002dr-87"></a><a name="index-g_t_002d_002drecursive-88"></a><a name="index-recursive-search-89"></a><a name="index-searching-directory-trees-90"></a>For each directory mentioned in the command line, read and process all
  217. files in that directory, recursively.  This is the same as the
  218. `<samp><span class="samp">--directories=recurse</span></samp>' option.
  219.  
  220.      <br><dt>`<samp><span class="samp">--include=</span><var>file_pattern</var></samp>'<dd><a name="index-g_t_002d_002dinclude-91"></a><a name="index-include-files-92"></a><a name="index-searching-directory-trees-93"></a>When processing directories recursively, only files matching <var>file_pattern</var>
  221. will be search.
  222.  
  223.      <br><dt>`<samp><span class="samp">--exclude=</span><var>file_pattern</var></samp>'<dd><a name="index-g_t_002d_002dexclude-94"></a><a name="index-exclude-files-95"></a><a name="index-searching-directory-trees-96"></a>When processing directories recursively, skip files matching <var>file_pattern</var>.
  224.  
  225.      <br><dt>`<samp><span class="samp">-m </span><var>num</var></samp>'<dt>`<samp><span class="samp">--max-count=</span><var>num</var></samp>'<dd><a name="index-g_t_002dm-97"></a><a name="index-g_t_002d_002dmax_002dcount-98"></a><a name="index-max_002dcount-99"></a>Stop reading a file after <var>num</var> matching lines.  If the input is
  226. standard input from a regular file, and <var>num</var> matching lines are
  227. output, <samp><span class="command">grep</span></samp> ensures that the standard input is positioned to
  228. just after the last matching line before exiting, regardless of the
  229. presence of trailing context lines.  This enables a calling process
  230. to resume a search.  For example, the following shell script makes use
  231. of it:
  232.  
  233.      <pre class="example">          while grep -m 1 PATTERN
  234.           do
  235.             echo xxxx
  236.           done < FILE
  237.      </pre>
  238.      <p>But the following probably will not work because a pipe is not a regular
  239. file:
  240.  
  241.      <pre class="example">          # This probably will not work.
  242.           cat FILE |
  243.           while grep -m 1 PATTERN
  244.           do
  245.             echo xxxx
  246.           done
  247.      </pre>
  248.      <p>When <samp><span class="command">grep</span></samp> stops after NUM matching lines, it outputs
  249. any trailing context lines. Since context does not include matching
  250. lines, <samp><span class="command">grep</span></samp> will stop when it encounters another matching line. 
  251. When the `<samp><span class="samp">-c</span></samp>' or `<samp><span class="samp">--count</span></samp>' option is also used,
  252. <samp><span class="command">grep</span></samp> does not output a count greater than <var>num</var>. 
  253. When the `<samp><span class="samp">-v</span></samp>' or `<samp><span class="samp">--invert-match</span></samp>' option is
  254. also used, <samp><span class="command">grep</span></samp> stops after outputting <var>num</var>
  255. non-matching lines.
  256.  
  257.      <br><dt>`<samp><span class="samp">-y</span></samp>'<dd><a name="index-g_t_002dy-100"></a><a name="index-case-insensitive-search_002c-obsolete-option-101"></a>Obsolete synonym for `<samp><span class="samp">-i</span></samp>'.
  258.  
  259.      <br><dt>`<samp><span class="samp">-U</span></samp>'<dt>`<samp><span class="samp">--binary</span></samp>'<dd><a name="index-g_t_002dU-102"></a><a name="index-g_t_002d_002dbinary-103"></a><a name="index-DOS_002fWindows-binary-files-104"></a><a name="index-binary-files_002c-DOS_002fWindows-105"></a>Treat the file(s) as binary.  By default, under <span class="sc">ms-dos</span>
  260. and MS-Windows, <samp><span class="command">grep</span></samp> guesses the file type by looking
  261. at the contents of the first 32kB read from the file. 
  262. If <samp><span class="command">grep</span></samp> decides the file is a text file, it strips the
  263. <code>CR</code> characters from the original file contents (to make
  264. regular expressions with <code>^</code> and <code>$</code> work correctly). 
  265. Specifying `<samp><span class="samp">-U</span></samp>' overrules this guesswork, causing all
  266. files to be read and passed to the matching mechanism
  267. verbatim; if the file is a text file with <code>CR/LF</code> pairs
  268. at the end of each line, this will cause some regular
  269. expressions to fail.  This option has no effect on platforms other than
  270. <span class="sc">ms-dos</span> and MS-Windows.
  271.  
  272.      <br><dt>`<samp><span class="samp">-u</span></samp>'<dt>`<samp><span class="samp">--unix-byte-offsets</span></samp>'<dd><a name="index-g_t_002du-106"></a><a name="index-g_t_002d_002dunix_002dbyte_002doffsets-107"></a><a name="index-DOS-byte-offsets-108"></a><a name="index-byte-offsets_002c-on-DOS_002fWindows-109"></a>Report Unix-style byte offsets.  This switch causes
  273. <samp><span class="command">grep</span></samp> to report byte offsets as if the file were Unix style
  274. text file, i.e., the byte offsets ignore the <code>CR</code> characters which were
  275. stripped.  This will produce results identical to running <samp><span class="command">grep</span></samp> on
  276. a Unix machine.  This option has no effect unless `<samp><span class="samp">-b</span></samp>'
  277. option is also used; it has no effect on platforms other than <span class="sc">ms-dos</span> and
  278. MS-Windows.
  279.  
  280.      <br><dt>`<samp><span class="samp">--mmap</span></samp>'<dd><a name="index-g_t_002d_002dmmap-110"></a><a name="index-memory-mapped-input-111"></a>If possible, use the <code>mmap</code> system call to read input, instead of
  281. the default <code>read</code> system call.  In some situations, `<samp><span class="samp">--mmap</span></samp>'
  282. yields better performance.  However, `<samp><span class="samp">--mmap</span></samp>' can cause undefined
  283. behavior (including core dumps) if an input file shrinks while
  284. <samp><span class="command">grep</span></samp> is operating, or if an I/O error occurs.
  285.  
  286.      <br><dt>`<samp><span class="samp">-Z</span></samp>'<dt>`<samp><span class="samp">--null</span></samp>'<dd><a name="index-g_t_002dZ-112"></a><a name="index-g_t_002d_002dnull-113"></a><a name="index-zero_002dterminated-file-names-114"></a>Output a zero byte (the <span class="sc">ascii</span> <code>NUL</code> character) instead of the
  287. character that normally follows a file name.  For example, `<samp><span class="samp">grep
  288. -lZ</span></samp>' outputs a zero byte after each file name instead of the usual
  289. newline.  This option makes the output unambiguous, even in the presence
  290. of file names containing unusual characters like newlines.  This option
  291. can be used with commands like `<samp><span class="samp">find -print0</span></samp>', `<samp><span class="samp">perl -0</span></samp>',
  292. `<samp><span class="samp">sort -z</span></samp>', and `<samp><span class="samp">xargs -0</span></samp>' to process arbitrary file names,
  293. even those that contain newline characters.
  294.  
  295.      <br><dt>`<samp><span class="samp">-z</span></samp>'<dt>`<samp><span class="samp">--null-data</span></samp>'<dd><a name="index-g_t_002dz-115"></a><a name="index-g_t_002d_002dnull_002ddata-116"></a><a name="index-zero_002dterminated-lines-117"></a>Treat the input as a set of lines, each terminated by a zero byte (the
  296. <span class="sc">ascii</span> <code>NUL</code> character) instead of a newline.  Like the `<samp><span class="samp">-Z</span></samp>'
  297. or `<samp><span class="samp">--null</span></samp>' option, this option can be used with commands like
  298. `<samp><span class="samp">sort -z</span></samp>' to process arbitrary file names.
  299.  
  300. </dl>
  301.  
  302.    <p>Several additional options control which variant of the <samp><span class="command">grep</span></samp>
  303. matching engine is used.  See <a href="#Grep-Programs">Grep Programs</a>.
  304.  
  305. <h3 class="section">2.2 Environment Variables</h3>
  306.  
  307. <p>Grep's behavior is affected by the following environment variables.
  308.  
  309.    <p>A locale <code>LC_</code><var>foo</var> is specified by examining the three
  310. environment variables <samp><span class="env">LC_ALL</span></samp>, <samp><span class="env">LC_</span><var>foo</var></samp>, and <samp><span class="env">LANG</span></samp>,
  311. in that order.  The first of these variables that is set specifies the
  312. locale.  For example, if <samp><span class="env">LC_ALL</span></samp> is not set, but <samp><span class="env">LC_MESSAGES</span></samp>
  313. is set to `<samp><span class="samp">pt_BR</span></samp>', then Brazilian Portuguese is used for the
  314. <code>LC_MESSAGES</code> locale.  The C locale is used if none of these
  315. environment variables are set, or if the locale catalog is not
  316. installed, or if <samp><span class="command">grep</span></samp> was not compiled with national language
  317. support (<span class="sc">nls</span>).
  318.  
  319.    <p><a name="index-environment-variables-118"></a>
  320.      <dl>
  321. <dt><samp><span class="env">GREP_OPTIONS</span></samp><dd><a name="index-GREP_005fOPTIONS-119"></a><a name="index-default-options-environment-variable-120"></a>This variable specifies default options to be placed in front of any
  322. explicit options.  For example, if <code>GREP_OPTIONS</code> is
  323. `<samp><span class="samp">--binary-files=without-match --directories=skip</span></samp>', <samp><span class="command">grep</span></samp>
  324. behaves as if the two options `<samp><span class="samp">--binary-files=without-match</span></samp>' and
  325. `<samp><span class="samp">--directories=skip</span></samp>' had been specified before
  326. any explicit options.  Option specifications are separated by
  327. whitespace.  A backslash escapes the next character, so it can be used to
  328. specify an option containing whitespace or a backslash.
  329.  
  330.      <br><dt><samp><span class="env">GREP_COLOR</span></samp><dd><a name="index-GREP_005fCOLOR-121"></a><a name="index-highlight-markers-122"></a>This variable specifies the surrounding markers use to highlight the matching
  331. text.  The default is control ascii red.
  332.  
  333.      <br><dt><samp><span class="env">LC_ALL</span></samp><dt><samp><span class="env">LC_COLLATE</span></samp><dt><samp><span class="env">LANG</span></samp><dd><a name="index-LC_005fALL-123"></a><a name="index-LC_005fCOLLATE-124"></a><a name="index-LANG-125"></a><a name="index-character-type-126"></a><a name="index-national-language-support-127"></a><a name="index-NLS-128"></a>These variables specify the <code>LC_COLLATE</code> locale, which determines
  334. the collating sequence used to interpret range expressions like
  335. `<samp><span class="samp">[a-z]</span></samp>'.
  336.  
  337.      <br><dt><samp><span class="env">LC_ALL</span></samp><dt><samp><span class="env">LC_CTYPE</span></samp><dt><samp><span class="env">LANG</span></samp><dd><a name="index-LC_005fALL-129"></a><a name="index-LC_005fCTYPE-130"></a><a name="index-LANG-131"></a><a name="index-character-type-132"></a><a name="index-national-language-support-133"></a><a name="index-NLS-134"></a>These variables specify the <code>LC_CTYPE</code> locale, which determines the
  338. type of characters, e.g., which characters are whitespace.
  339.  
  340.      <br><dt><samp><span class="env">LC_ALL</span></samp><dt><samp><span class="env">LC_MESSAGES</span></samp><dt><samp><span class="env">LANG</span></samp><dd><a name="index-LC_005fALL-135"></a><a name="index-LC_005fMESSAGES-136"></a><a name="index-LANG-137"></a><a name="index-language-of-messages-138"></a><a name="index-message-language-139"></a><a name="index-national-language-support-140"></a><a name="index-NLS-141"></a><a name="index-translation-of-message-language-142"></a>These variables specify the <code>LC_MESSAGES</code> locale, which determines
  341. the language that <samp><span class="command">grep</span></samp> uses for messages.  The default C
  342. locale uses American English messages.
  343.  
  344.      <br><dt><samp><span class="env">POSIXLY_CORRECT</span></samp><dd><a name="index-POSIXLY_005fCORRECT-143"></a>If set, <samp><span class="command">grep</span></samp> behaves as <span class="sc">posix.2</span> requires; otherwise,
  345. <samp><span class="command">grep</span></samp> behaves more like other <span class="sc">gnu</span> programs.  <span class="sc">posix.2</span>
  346. requires that options that
  347. follow file names must be treated as file names; by default, such
  348. options are permuted to the front of the operand list and are treated as
  349. options.  Also, <span class="sc">posix.2</span> requires that unrecognized options be
  350. diagnosed as
  351. “illegal”, but since they are not really against the law the default
  352. is to diagnose them as “invalid”.  <code>POSIXLY_CORRECT</code> also
  353. disables <code>_</code><var>N</var><code>_GNU_nonoption_argv_flags_</code>, described below.
  354.  
  355.      <br><dt><samp><span class="env">_</span><var>N</var><span class="env">_GNU_nonoption_argv_flags_</span></samp><dd><a name="index-g_t_005f_0040var_007bN_007d_005fGNU_005fnonoption_005fargv_005fflags_005f-144"></a>(Here <var>N</var> is <samp><span class="command">grep</span></samp>'s numeric process ID.)  If the
  356. <var>i</var>th character of this environment variable's value is `<samp><span class="samp">1</span></samp>', do
  357. not consider the <var>i</var>th operand of <samp><span class="command">grep</span></samp> to be an option, even if
  358. it appears to be one.  A shell can put this variable in the environment
  359. for each command it runs, specifying which operands are the results of
  360. file name wildcard expansion and therefore should not be treated as
  361. options.  This behavior is available only with the <span class="sc">gnu</span> C library, and
  362. only when <code>POSIXLY_CORRECT</code> is not set.
  363.  
  364.    </dl>
  365.  
  366. <div class="node">
  367. <p><hr>
  368. <a name="Diagnostics"></a>
  369. Next: <a rel="next" accesskey="n" href="#Grep-Programs">Grep Programs</a>,
  370. Previous: <a rel="previous" accesskey="p" href="#Invoking">Invoking</a>,
  371. Up: <a rel="up" accesskey="u" href="#Top">Top</a>
  372.  
  373. </div>
  374.  
  375. <h2 class="chapter">3 Diagnostics</h2>
  376.  
  377. <p>Normally, exit status is 0 if selected lines are found and 1 otherwise. 
  378. But the exit status is 2 if an error occurred, unless the <samp><span class="option">-q</span></samp> or
  379. <samp><span class="option">--quiet</span></samp> or <samp><span class="option">--silent</span></samp> option is used and a selected line
  380. is found.
  381.  
  382. <div class="node">
  383. <p><hr>
  384. <a name="Grep-Programs"></a>
  385. Next: <a rel="next" accesskey="n" href="#Regular-Expressions">Regular Expressions</a>,
  386. Previous: <a rel="previous" accesskey="p" href="#Diagnostics">Diagnostics</a>,
  387. Up: <a rel="up" accesskey="u" href="#Top">Top</a>
  388.  
  389. </div>
  390.  
  391. <h2 class="chapter">4 <samp><span class="command">grep</span></samp> programs</h2>
  392.  
  393. <p><samp><span class="command">grep</span></samp> searches the named input files (or standard input if no
  394. files are named, or the file name <samp><span class="file">-</span></samp> is given) for lines containing
  395. a match to the given pattern.  By default, <samp><span class="command">grep</span></samp> prints the
  396. matching lines.  There are four major variants of <samp><span class="command">grep</span></samp>,
  397. controlled by the following options.
  398.  
  399.      <dl>
  400. <dt>`<samp><span class="samp">-G</span></samp>'<dt>`<samp><span class="samp">--basic-regexp</span></samp>'<dd><a name="index-g_t_002dG-145"></a><a name="index-g_t_002d_002dbasic_002dregexp-146"></a><a name="index-matching-basic-regular-expressions-147"></a>Interpret the pattern as a basic regular expression.  This is the default.
  401.  
  402.      <br><dt>`<samp><span class="samp">-E</span></samp>'<dt>`<samp><span class="samp">--extended-regexp</span></samp>'<dd><a name="index-g_t_002dE-148"></a><a name="index-g_t_002d_002dextended_002dregexp-149"></a><a name="index-matching-extended-regular-expressions-150"></a>Interpret the pattern as an extended regular expression.
  403.  
  404.      <br><dt>`<samp><span class="samp">-F</span></samp>'<dt>`<samp><span class="samp">--fixed-strings</span></samp>'<dd><a name="index-g_t_002dF-151"></a><a name="index-g_t_002d_002dfixed_002dstrings-152"></a><a name="index-matching-fixed-strings-153"></a>Interpret the pattern as a list of fixed strings, separated
  405. by newlines, any of which is to be matched.
  406.  
  407.      <br><dt>`<samp><span class="samp">-P</span></samp>'<dt>`<samp><span class="samp">--perl-regexp</span></samp>'<dd><a name="index-g_t_002dP-154"></a><a name="index-g_t_002d_002dperl_002dregexp-155"></a><a name="index-matching-Perl-regular-expressions-156"></a>Interpret the pattern as a Perl regular expression.
  408.  
  409.    </dl>
  410.  
  411.    <p>In addition, two variant programs <span class="sc">egrep</span> and <span class="sc">fgrep</span> are available. 
  412. <span class="sc">egrep</span> is the same as `<samp><span class="samp">grep -E</span></samp>'.  <span class="sc">fgrep</span> is the
  413. same as `<samp><span class="samp">grep -F</span></samp>'.
  414.  
  415. <div class="node">
  416. <p><hr>
  417. <a name="Regular-Expressions"></a>
  418. Next: <a rel="next" accesskey="n" href="#Usage">Usage</a>,
  419. Previous: <a rel="previous" accesskey="p" href="#Grep-Programs">Grep Programs</a>,
  420. Up: <a rel="up" accesskey="u" href="#Top">Top</a>
  421.  
  422. </div>
  423.  
  424. <h2 class="chapter">5 Regular Expressions</h2>
  425.  
  426. <p><a name="index-regular-expressions-157"></a>
  427. A <dfn>regular expression</dfn> is a pattern that describes a set of strings. 
  428. Regular expressions are constructed analogously to arithmetic expressions,
  429. by using various operators to combine smaller expressions. 
  430. <samp><span class="command">grep</span></samp> understands two different versions of regular expression
  431. syntax: “basic”(BRE) and “extended”(ERE).  In <span class="sc">gnu</span> <samp><span class="command">grep</span></samp>,
  432. there is no difference in available functionality using either syntax. 
  433. In other implementations, basic regular expressions are less powerful. 
  434. The following description applies to extended regular expressions;
  435. differences for basic regular expressions are summarized afterwards.
  436.  
  437.    <p>The fundamental building blocks are the regular expressions that match
  438. a single character.  Most characters, including all letters and digits,
  439. are regular expressions that match themselves.  Any metacharacter
  440. with special meaning may be quoted by preceding it with a backslash.
  441.  
  442.    <p>A regular expression may be followed by one of several
  443. repetition operators:
  444.  
  445.      <dl>
  446. <dt>`<samp><span class="samp">.</span></samp>'<dd><a name="index-g_t_002e-158"></a><a name="index-dot-159"></a><a name="index-period-160"></a>The period `<samp><span class="samp">.</span></samp>' matches any single character.
  447.  
  448.      <br><dt>`<samp><span class="samp">?</span></samp>'<dd><a name="index-g_t_003f-161"></a><a name="index-question-mark-162"></a><a name="index-match-sub_002dexpression-at-most-once-163"></a>The preceding item is optional and will be matched at most once.
  449.  
  450.      <br><dt>`<samp><span class="samp">*</span></samp>'<dd><a name="index-g_t_002a-164"></a><a name="index-asterisk-165"></a><a name="index-match-sub_002dexpression-zero-or-more-times-166"></a>The preceding item will be matched zero or more times.
  451.  
  452.      <br><dt>`<samp><span class="samp">+</span></samp>'<dd><a name="index-g_t_002b-167"></a><a name="index-plus-sign-168"></a>The preceding item will be matched one or more times.
  453.  
  454.      <br><dt>`<samp><span class="samp">{</span><var>n</var><span class="samp">}</span></samp>'<dd><a name="index-g_t_0040_007bn_0040_007d-169"></a><a name="index-braces_002c-one-argument-170"></a><a name="index-match-sub_002dexpression-n-times-171"></a>The preceding item is matched exactly <var>n</var> times.
  455.  
  456.      <br><dt>`<samp><span class="samp">{</span><var>n</var><span class="samp">,}</span></samp>'<dd><a name="index-g_t_0040_007bn_002c_0040_007d-172"></a><a name="index-braces_002c-second-argument-omitted-173"></a><a name="index-match-sub_002dexpression-n-or-more-times-174"></a>The preceding item is matched n or more times.
  457.  
  458.      <br><dt>`<samp><span class="samp">{</span><var>n</var><span class="samp">,</span><var>m</var><span class="samp">}</span></samp>'<dd><a name="index-g_t_0040_007bn_002cm_0040_007d-175"></a><a name="index-braces_002c-two-arguments-176"></a>The preceding item is matched at least <var>n</var> times, but not more than
  459. <var>m</var> times.
  460.  
  461.    </dl>
  462.  
  463.    <p>Two regular expressions may be concatenated; the resulting regular
  464. expression matches any string formed by concatenating two substrings
  465. that respectively match the concatenated subexpressions.
  466.  
  467.    <p>Two regular expressions may be joined by the infix operator `<samp><span class="samp">|</span></samp>'; the
  468. resulting regular expression matches any string matching either subexpression.
  469.  
  470.    <p>Repetition takes precedence over concatenation, which in turn
  471. takes precedence over alternation.  A whole subexpression may be
  472. enclosed in parentheses to override these precedence rules.
  473.  
  474. <h3 class="section">5.1 Character Class</h3>
  475.  
  476. <p><a name="index-bracket-expression-177"></a><a name="index-character-class-178"></a>A <dfn>bracket expression</dfn> is a list of characters enclosed by `<samp><span class="samp">[</span></samp>' and
  477. `<samp><span class="samp">]</span></samp>'.  It matches any single character in that list; if the first
  478. character of the list is the caret `<samp><span class="samp">^</span></samp>', then it matches any character
  479. <strong>not</strong> in the list.  For example, the regular expression
  480. `<samp><span class="samp">[0123456789]</span></samp>' matches any single digit.
  481.  
  482.    <p><a name="index-range-expression-179"></a>Within a bracket expression, a <dfn>range expression</dfn> consists of two
  483. characters separated by a hyphen.  It matches any single character that
  484. sorts between the two characters, inclusive, using the locale's
  485. collating sequence and character set.  For example, in the default C
  486. locale, `<samp><span class="samp">[a-d]</span></samp>' is equivalent to `<samp><span class="samp">[abcd]</span></samp>'.  Many locales sort
  487. characters in dictionary order, and in these locales `<samp><span class="samp">[a-d]</span></samp>' is
  488. typically not equivalent to `<samp><span class="samp">[abcd]</span></samp>'; it might be equivalent to
  489. `<samp><span class="samp">[aBbCcDd]</span></samp>', for example.  To obtain the traditional interpretation
  490. of bracket expressions, you can use the C locale by setting the
  491. <samp><span class="env">LC_ALL</span></samp> environment variable to the value `<samp><span class="samp">C</span></samp>'.
  492.  
  493.    <p>Finally, certain named classes of characters are predefined within
  494. bracket expressions, as follows. 
  495. Their interpretation depends on the <code>LC_CTYPE</code> locale; the
  496. interpretation below is that of the C locale, which is the default
  497. if no <code>LC_CTYPE</code> locale is specified.
  498.  
  499.    <p><a name="index-classes-of-characters-180"></a><a name="index-character-classes-181"></a>
  500.      <dl>
  501. <dt>`<samp><span class="samp">[:alnum:]</span></samp>'<dd><a name="index-alnum-182"></a><a name="index-alphanumeric-characters-183"></a>Alphanumeric characters:
  502. `<samp><span class="samp">[:alpha:]</span></samp>' and `<samp><span class="samp">[:digit:]</span></samp>'.
  503.  
  504.      <br><dt>`<samp><span class="samp">[:alpha:]</span></samp>'<dd><a name="index-alpha-184"></a><a name="index-alphabetic-characters-185"></a>Alphabetic characters:
  505. `<samp><span class="samp">[:lower:]</span></samp>' and `<samp><span class="samp">[:upper:]</span></samp>'.
  506.  
  507.      <br><dt>`<samp><span class="samp">[:blank:]</span></samp>'<dd><a name="index-blank-186"></a><a name="index-blank-characters-187"></a>Blank characters:
  508. space and tab.
  509.  
  510.      <br><dt>`<samp><span class="samp">[:cntrl:]</span></samp>'<dd><a name="index-cntrl-188"></a><a name="index-control-characters-189"></a>Control characters.  In <span class="sc">ascii</span>, these characters have octal codes 000
  511. through 037, and 177 (<code>DEL</code>).  In other character sets, these are
  512. the equivalent characters, if any.
  513.  
  514.      <br><dt>`<samp><span class="samp">[:digit:]</span></samp>'<dd><a name="index-digit-190"></a><a name="index-digit-characters-191"></a><a name="index-numeric-characters-192"></a>Digits: <code>0 1 2 3 4 5 6 7 8 9</code>.
  515.  
  516.      <br><dt>`<samp><span class="samp">[:graph:]</span></samp>'<dd><a name="index-graph-193"></a><a name="index-graphic-characters-194"></a>Graphical characters:
  517. `<samp><span class="samp">[:alnum:]</span></samp>' and `<samp><span class="samp">[:punct:]</span></samp>'.
  518.  
  519.      <br><dt>`<samp><span class="samp">[:lower:]</span></samp>'<dd><a name="index-lower-195"></a><a name="index-lower_002dcase-letters-196"></a>Lower-case letters:
  520. <code>a b c d e f g h i j k l m n o p q r s t u v w x y z</code>.
  521.  
  522.      <br><dt>`<samp><span class="samp">[:print:]</span></samp>'<dd><a name="index-print-197"></a><a name="index-printable-characters-198"></a>Printable characters:
  523. `<samp><span class="samp">[:alnum:]</span></samp>', `<samp><span class="samp">[:punct:]</span></samp>', and space.
  524.  
  525.      <br><dt>`<samp><span class="samp">[:punct:]</span></samp>'<dd><a name="index-punct-199"></a><a name="index-punctuation-characters-200"></a>Punctuation characters:
  526. <code>! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~</code>.
  527.  
  528.      <br><dt>`<samp><span class="samp">[:space:]</span></samp>'<dd><a name="index-space-201"></a><a name="index-space-characters-202"></a><a name="index-whitespace-characters-203"></a>Space characters:
  529. tab, newline, vertical tab, form feed, carriage return, and space.
  530.  
  531.      <br><dt>`<samp><span class="samp">[:upper:]</span></samp>'<dd><a name="index-upper-204"></a><a name="index-upper_002dcase-letters-205"></a>Upper-case letters:
  532. <code>A B C D E F G H I J K L M N O P Q R S T U V W X Y Z</code>.
  533.  
  534.      <br><dt>`<samp><span class="samp">[:xdigit:]</span></samp>'<dd><a name="index-xdigit-206"></a><a name="index-xdigit-class-207"></a><a name="index-hexadecimal-digits-208"></a>Hexadecimal digits:
  535. <code>0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f</code>.
  536.  
  537.    </dl>
  538.    For example, `<samp><span class="samp">[[:alnum:]]</span></samp>' means `<samp><span class="samp">[0-9A-Za-z]</span></samp>', except the latter
  539. depends upon the C locale and the <span class="sc">ascii</span> character
  540. encoding, whereas the former is independent of locale and character set. 
  541. (Note that the brackets in these class names are
  542. part of the symbolic names, and must be included in addition to
  543. the brackets delimiting the bracket list.)
  544.  
  545.    <p>Most metacharacters lose their special meaning inside lists.
  546.  
  547.      <dl>
  548. <dt>`<samp><span class="samp">]</span></samp>'<dd>ends the list if it's not the first list item.  So, if you want to make
  549. the `<samp><span class="samp">]</span></samp>' character a list item, you must put it first.
  550.  
  551.      <br><dt>`<samp><span class="samp">[.</span></samp>'<dd>represents the open collating symbol.
  552.  
  553.      <br><dt>`<samp><span class="samp">.]</span></samp>'<dd>represents the close collating symbol.
  554.  
  555.      <br><dt>`<samp><span class="samp">[=</span></samp>'<dd>represents the open equivalence class.
  556.  
  557.      <br><dt>`<samp><span class="samp">=]</span></samp>'<dd>represents the close equivalence class.
  558.  
  559.      <br><dt>`<samp><span class="samp">[:</span></samp>'<dd>represents the open character class followed by a valid character class name.
  560.  
  561.      <br><dt>`<samp><span class="samp">:]</span></samp>'<dd>represents the close character class followed by a valid character class name.
  562.  
  563.      <br><dt>`<samp><span class="samp">-</span></samp>'<dd>represents the range if it's not first or last in a list or the ending point
  564. of a range.
  565.  
  566.      <br><dt>`<samp><span class="samp">^</span></samp>'<dd>represents the characters not in the list.  If you want to make the `<samp><span class="samp">^</span></samp>'
  567. character a list item, place it anywhere but first.
  568.  
  569.    </dl>
  570.  
  571. <h3 class="section">5.2 Backslash Character</h3>
  572.  
  573. <p><a name="index-backslash-209"></a>
  574. The `<samp><span class="samp">\</span></samp>' when followed by certain ordinary characters take a special
  575. meaning :
  576.  
  577.      <dl>
  578. <dt>`<samp><span class="samp">`<samp></span><span class="samp">\b</span><span class="samp"></samp>'</span></samp>'<dd>Match the empty string at the edge of a word.
  579.  
  580.      <br><dt>`<samp><span class="samp">`<samp></span><span class="samp">\B</span><span class="samp"></samp>'</span></samp>'<dd>Match the empty string provided it's not at the edge of a word.
  581.  
  582.      <br><dt>`<samp><span class="samp">`<samp></span><span class="samp">\<</span><span class="samp"></samp>'</span></samp>'<dd>Match the empty string at the beginning of word.
  583.  
  584.      <br><dt>`<samp><span class="samp">`<samp></span><span class="samp">\></span><span class="samp"></samp>'</span></samp>'<dd>Match the empty string at the end of word.
  585.  
  586.      <br><dt>`<samp><span class="samp">`<samp></span><span class="samp">\w</span><span class="samp"></samp>'</span></samp>'<dd>Match word constituent, it is a synonym for `<samp><span class="samp">[[:alnum:]]</span></samp>'.
  587.  
  588.      <br><dt>`<samp><span class="samp">`<samp></span><span class="samp">\W</span><span class="samp"></samp>'</span></samp>'<dd>Match non word constituent, it is a synonym for `<samp><span class="samp">[^[:alnum:]]</span></samp>'.
  589.  
  590.    </dl>
  591.  
  592.    <p>For example , `<samp><span class="samp">\brat\b</span></samp>' matches the separate word `<samp><span class="samp">rat</span></samp>',
  593. `<samp><span class="samp">c\Brat\Be</span></samp>' matches `<samp><span class="samp">crate</span></samp>', but `<samp><span class="samp">dirty \Brat</span></samp>' doesn't
  594. match `<samp><span class="samp">dirty rat</span></samp>'.
  595.  
  596. <h3 class="section">5.3 Anchoring</h3>
  597.  
  598. <p><a name="index-anchoring-210"></a>
  599. The caret `<samp><span class="samp">^</span></samp>' and the dollar sign `<samp><span class="samp">$</span></samp>' are metacharacters that
  600. respectively match the empty string at the beginning and end of a line.
  601.  
  602. <h3 class="section">5.4 Back-reference</h3>
  603.  
  604. <p><a name="index-back_002dreference-211"></a>
  605. The back-reference `<samp><span class="samp">\</span><var>n</var></samp>', where <var>n</var> is a single digit, matches
  606. the substring previously matched by the <var>n</var>th parenthesized subexpression
  607. of the regular expression. For example, `<samp><span class="samp">(a)\1</span></samp>' matches `<samp><span class="samp">aa</span></samp>'. 
  608. When use with alternation if the group does not participate in the match, then
  609. the back-reference makes the whole match fail.  For example, `<samp><span class="samp">a(.)|b\1</span></samp>'
  610. will not match `<samp><span class="samp">ba</span></samp>'.  When multiple regular expressions are given with
  611. `<samp><span class="samp">-e</span></samp>' or from a file `<samp><span class="samp">-f file</span></samp>', the back-referecences are local to
  612. each expression.
  613.  
  614. <h3 class="section">5.5 Basic vs Extended</h3>
  615.  
  616. <p><a name="index-basic-regular-expressions-212"></a>
  617. In basic regular expressions the metacharacters `<samp><span class="samp">?</span></samp>', `<samp><span class="samp">+</span></samp>',
  618. `<samp><span class="samp">{</span></samp>', `<samp><span class="samp">|</span></samp>', `<samp><span class="samp">(</span></samp>', and `<samp><span class="samp">)</span></samp>' lose their special meaning;
  619. instead use the backslashed versions `<samp><span class="samp">\?</span></samp>', `<samp><span class="samp">\+</span></samp>', `<samp><span class="samp">\{</span></samp>',
  620. `<samp><span class="samp">\|</span></samp>', `<samp><span class="samp">\(</span></samp>', and `<samp><span class="samp">\)</span></samp>'.
  621.  
  622.    <p><a name="index-interval-specifications-213"></a>Traditional <samp><span class="command">egrep</span></samp> did not support the `<samp><span class="samp">{</span></samp>' metacharacter,
  623. and some <samp><span class="command">egrep</span></samp> implementations support `<samp><span class="samp">\{</span></samp>' instead, so
  624. portable scripts should avoid `<samp><span class="samp">{</span></samp>' in `<samp><span class="samp">egrep</span></samp>' patterns and
  625. should use `<samp><span class="samp">[{]</span></samp>' to match a literal `<samp><span class="samp">{</span></samp>'.
  626.  
  627.    <p><span class="sc">gnu</span> <samp><span class="command">egrep</span></samp> attempts to support traditional usage by
  628. assuming that `<samp><span class="samp">{</span></samp>' is not special if it would be the start of an
  629. invalid interval specification.  For example, the shell command
  630. `<samp><span class="samp">egrep '{1'</span></samp>' searches for the two-character string `<samp><span class="samp">{1</span></samp>'
  631. instead of reporting a syntax error in the regular expression. 
  632. <span class="sc">posix.2</span> allows this behavior as an extension, but portable scripts
  633. should avoid it.
  634.  
  635. <div class="node">
  636. <p><hr>
  637. <a name="Usage"></a>
  638. Next: <a rel="next" accesskey="n" href="#Reporting-Bugs">Reporting Bugs</a>,
  639. Previous: <a rel="previous" accesskey="p" href="#Regular-Expressions">Regular Expressions</a>,
  640. Up: <a rel="up" accesskey="u" href="#Top">Top</a>
  641.  
  642. </div>
  643.  
  644. <h2 class="chapter">6 Usage</h2>
  645.  
  646. <p><a name="index-Usage_002c-examples-214"></a>Here is an example shell command that invokes <span class="sc">gnu</span> <samp><span class="command">grep</span></samp>:
  647.  
  648. <pre class="example">     grep -i 'hello.*world' menu.h main.c
  649. </pre>
  650.    <p class="noindent">This lists all lines in the files <samp><span class="file">menu.h</span></samp> and <samp><span class="file">main.c</span></samp> that
  651. contain the string `<samp><span class="samp">hello</span></samp>' followed by the string `<samp><span class="samp">world</span></samp>';
  652. this is because `<samp><span class="samp">.*</span></samp>' matches zero or more characters within a line. 
  653. See <a href="#Regular-Expressions">Regular Expressions</a>.  The `<samp><span class="samp">-i</span></samp>' option causes <samp><span class="command">grep</span></samp>
  654. to ignore case, causing it to match the line `<samp><span class="samp">Hello, world!</span></samp>', which
  655. it would not otherwise match.  See <a href="#Invoking">Invoking</a>, for more details about
  656. how to invoke <samp><span class="command">grep</span></samp>.
  657.  
  658.    <p><a name="index-Using-_0040command_007bgrep_007d_002c-Q_0026A-215"></a><a name="index-FAQ-about-_0040command_007bgrep_007d-usage-216"></a>Here are some common questions and answers about <samp><span class="command">grep</span></samp> usage.
  659.  
  660.      <ol type=1 start=1>
  661.  
  662.      <li>How can I list just the names of matching files?
  663.  
  664.      <pre class="example">          grep -l 'main' *.c
  665.      </pre>
  666.      <p class="noindent">lists the names of all C files in the current directory whose contents
  667. mention `<samp><span class="samp">main</span></samp>'.
  668.  
  669.      <li>How do I search directories recursively?
  670.  
  671.      <pre class="example">          grep -r 'hello' /home/gigi
  672.      </pre>
  673.      <p class="noindent">searches for `<samp><span class="samp">hello</span></samp>' in all files under the directory
  674. <samp><span class="file">/home/gigi</span></samp>.  For more control of which files are searched, use
  675. <samp><span class="command">find</span></samp>, <samp><span class="command">grep</span></samp> and <samp><span class="command">xargs</span></samp>.  For example,
  676. the following command searches only C files:
  677.  
  678.      <pre class="smallexample">          find /home/gigi -name '*.c' -print | xargs grep 'hello' /dev/null
  679.      </pre>
  680.      <p>This differs from the command:
  681.  
  682.      <pre class="example">          grep -r 'hello' *.c
  683.      </pre>
  684.      <p>which merely looks for `<samp><span class="samp">hello</span></samp>' in all files in the current
  685. directory whose names end in `<samp><span class="samp">.c</span></samp>'.  Here the <samp><span class="option">-r</span></samp> is
  686. probably unnecessary, as recursion occurs only in the unlikely event
  687. that one of `<samp><span class="samp">.c</span></samp>' files is a directory.
  688.  
  689.      <li>What if a pattern has a leading `<samp><span class="samp">-</span></samp>'?
  690.  
  691.      <pre class="example">          grep -e '--cut here--' *
  692.      </pre>
  693.      <p class="noindent">searches for all lines matching `<samp><span class="samp">--cut here--</span></samp>'.  Without `<samp><span class="samp">-e</span></samp>',
  694. <samp><span class="command">grep</span></samp> would attempt to parse `<samp><span class="samp">--cut here--</span></samp>' as a list of
  695. options.
  696.  
  697.      <li>Suppose I want to search for a whole word, not a part of a word?
  698.  
  699.      <pre class="example">          grep -w 'hello' *
  700.      </pre>
  701.      <p class="noindent">searches only for instances of `<samp><span class="samp">hello</span></samp>' that are entire words; it
  702. does not match `<samp><span class="samp">Othello</span></samp>'.  For more control, use `<samp><span class="samp">\<</span></samp>' and
  703. `<samp><span class="samp">\></span></samp>' to match the start and end of words.  For example:
  704.  
  705.      <pre class="example">          grep 'hello\>' *
  706.      </pre>
  707.      <p class="noindent">searches only for words ending in `<samp><span class="samp">hello</span></samp>', so it matches the word
  708. `<samp><span class="samp">Othello</span></samp>'.
  709.  
  710.      <li>How do I output context around the matching lines?
  711.  
  712.      <pre class="example">          grep -C 2 'hello' *
  713.      </pre>
  714.      <p class="noindent">prints two lines of context around each matching line.
  715.  
  716.      <li>How do I force grep to print the name of the file?
  717.  
  718.      <p>Append <samp><span class="file">/dev/null</span></samp>:
  719.  
  720.      <pre class="example">          grep 'eli' /etc/passwd /dev/null
  721.      </pre>
  722.      <p>gets you:
  723.  
  724.      <pre class="smallexample">          /etc/passwd:eli:DNGUTF58.IMe.:98:11:Eli Smith:/home/do/eli:/bin/bash
  725.      </pre>
  726.      <li>Why do people use strange regular expressions on <samp><span class="command">ps</span></samp> output?
  727.  
  728.      <pre class="example">          ps -ef | grep '[c]ron'
  729.      </pre>
  730.      <p>If the pattern had been written without the square brackets, it would
  731. have matched not only the <samp><span class="command">ps</span></samp> output line for <samp><span class="command">cron</span></samp>,
  732. but also the <samp><span class="command">ps</span></samp> output line for <samp><span class="command">grep</span></samp>. 
  733. Note that some platforms <samp><span class="command">ps</span></samp> limit the ouput to the width
  734. of the screen, grep does not have any limit on the length of a line
  735. except the available memory.
  736.  
  737.      <li>Why does <samp><span class="command">grep</span></samp> report “Binary file matches”?
  738.  
  739.      <p>If <samp><span class="command">grep</span></samp> listed all matching “lines” from a binary file, it
  740. would probably generate output that is not useful, and it might even
  741. muck up your display.  So <span class="sc">gnu</span> <samp><span class="command">grep</span></samp> suppresses output from
  742. files that appear to be binary files.  To force <span class="sc">gnu</span> <samp><span class="command">grep</span></samp>
  743. to output lines even from files that appear to be binary, use the
  744. `<samp><span class="samp">-a</span></samp>' or `<samp><span class="samp">--binary-files=text</span></samp>' option.  To eliminate the
  745. “Binary file matches” messages, use the `<samp><span class="samp">-I</span></samp>' or
  746. `<samp><span class="samp">--binary-files=without-match</span></samp>' option.
  747.  
  748.      <li>Why doesn't `<samp><span class="samp">grep -lv</span></samp>' print nonmatching file names?
  749.  
  750.      <p>`<samp><span class="samp">grep -lv</span></samp>' lists the names of all files containing one or more
  751. lines that do not match.  To list the names of all files that contain no
  752. matching lines, use the `<samp><span class="samp">-L</span></samp>' or `<samp><span class="samp">--files-without-match</span></samp>'
  753. option.
  754.  
  755.      <li>I can do <span class="sc">or</span> with `<samp><span class="samp">|</span></samp>', but what about <span class="sc">and</span>?
  756.  
  757.      <pre class="example">          grep 'paul' /etc/motd | grep 'franc,ois'
  758.      </pre>
  759.      <p class="noindent">finds all lines that contain both `<samp><span class="samp">paul</span></samp>' and `<samp><span class="samp">franc,ois</span></samp>'.
  760.  
  761.      <li>How can I search in both standard input and in files?
  762.  
  763.      <p>Use the special file name `<samp><span class="samp">-</span></samp>':
  764.  
  765.      <pre class="example">          cat /etc/passwd | grep 'alain' - /etc/motd
  766.      </pre>
  767.      <li><a name="index-palindromes-217"></a>How to express palindromes in a regular expression?
  768.  
  769.      <p>It can be done by using the back referecences, for example a palindrome
  770. of 4 chararcters can be written in BRE.
  771.  
  772.      <pre class="example">          grep -w -e '\(.\)\(.\).\2\1' file
  773.      </pre>
  774.      <p>It matches the word "radar" or "civic".
  775.  
  776.      <p>Guglielmo Bondioni proposed a single RE that finds all the palindromes up to 19
  777. characters long.
  778.  
  779.      <pre class="example">          egrep -e '^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\9\8\7\6\5\4\3\2\1$' file
  780.      </pre>
  781.      <p>Note this is done by using GNU ERE extensions, it might not be portable on
  782. other greps.
  783.  
  784.      <li>Why are my expressions whith the vertical bar fail?
  785.  
  786.      <pre class="example">          /bin/echo "ba" | egrep '(a)\1|(b)\1'
  787.      </pre>
  788.      <p>The first alternate branch fails then the first group was not in the match
  789. this will make the second alternate branch fails.  For example, "aaba" will
  790. match, the first group participate in the match and can be reuse in the
  791. second branch.
  792.  
  793.      <li>What do <samp><span class="command">grep, fgrep, egrep</span></samp> stand for ?
  794.  
  795.      <p>grep comes from the way line editing was done on Unix.  For example,
  796. <samp><span class="command">ed</span></samp> uses this syntax to print a list of matching lines on the screen.
  797.  
  798.      <pre class="example">          global/regular expression/print
  799.           g/re/p
  800.      </pre>
  801.      <p><samp><span class="command">fgrep</span></samp> stands for Fixed <samp><span class="command">grep</span></samp>, <samp><span class="command">egrep</span></samp> Extended
  802. <samp><span class="command">grep</span></samp>.
  803.  
  804.         </ol>
  805.  
  806. <div class="node">
  807. <p><hr>
  808. <a name="Reporting-Bugs"></a>
  809. Next: <a rel="next" accesskey="n" href="#Copying">Copying</a>,
  810. Previous: <a rel="previous" accesskey="p" href="#Usage">Usage</a>,
  811. Up: <a rel="up" accesskey="u" href="#Top">Top</a>
  812.  
  813. </div>
  814.  
  815. <h2 class="chapter">7 Reporting bugs</h2>
  816.  
  817. <p><a name="index-Bugs_002c-reporting-218"></a>Email bug reports to <a href="mailto:bug-gnu-utils@gnu.org">bug-gnu-utils@gnu.org</a>. 
  818. Be sure to include the word “grep” somewhere in the “Subject:” field.
  819.  
  820.    <p>Large repetition counts in the `<samp><span class="samp">{n,m}</span></samp>' construct may cause
  821. <samp><span class="command">grep</span></samp> to use lots of memory.  In addition, certain other
  822. obscure regular expressions require exponential time and
  823. space, and may cause grep to run out of memory. 
  824. Back-references are very slow, and may require exponential time.
  825.  
  826. <div class="node">
  827. <p><hr>
  828. <a name="Copying"></a>
  829. Next: <a rel="next" accesskey="n" href="#GNU-General-Public-License">GNU General Public License</a>,
  830. Previous: <a rel="previous" accesskey="p" href="#Reporting-Bugs">Reporting Bugs</a>,
  831. Up: <a rel="up" accesskey="u" href="#Top">Top</a>
  832.  
  833. </div>
  834.  
  835. <h2 class="chapter">8 Copying</h2>
  836.  
  837. <p><a name="index-Copying-219"></a>GNU grep is licensed under the GNU GPL, which makes it <dfn>free
  838. software</dfn>.
  839.  
  840.    <p>Please note that “free” in “free software” refers to liberty, not
  841. price.  As some GNU project advocates like to point out, think of “free
  842. speech” rather than “free beer”.  The exact and legally binding
  843. distribution terms are spelled out below; in short, you have the right
  844. (freedom) to run and change grep and distribute it to other people, and
  845. even—if you want—charge money for doing either.  The important
  846. restriction is that you have to grant your recipients the same rights
  847. and impose the same restrictions.
  848.  
  849.    <p>This method of licensing software is also known as <dfn>open source</dfn>
  850. because, among other things, it makes sure that all recipients will
  851. receive the source code along with the program, and be able to improve
  852. it.  The GNU project prefers the term “free software” for reasons
  853. outlined at
  854. <a href="http://www.gnu.org/philosophy/free-software-for-freedom.html">http://www.gnu.org/philosophy/free-software-for-freedom.html</a>.
  855.  
  856.    <p>The exact license terms are defined by this paragraph and the GNU
  857. General Public License it refers to:
  858.  
  859.    <blockquote>
  860. GNU grep is free software; you can redistribute it and/or modify it
  861. under the terms of the GNU General Public License as published by the
  862. Free Software Foundation; either version 2 of the License, or (at your
  863. option) any later version.
  864.  
  865.         <p>GNU grep is distributed in the hope that it will be useful, but WITHOUT
  866. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  867. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  868. for more details.
  869.  
  870.         <p>A copy of the GNU General Public License is included as part of this
  871. manual; if you did not receive it, write to the Free Software
  872. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
  873. </blockquote>
  874.  
  875.    <p>In addition to this, this manual is free in the same sense:
  876.  
  877.    <blockquote>
  878. Permission is granted to copy, distribute and/or modify this document
  879. under the terms of the GNU Free Documentation License, Version 1.1 or
  880. any later version published by the Free Software Foundation; with the
  881. Invariant Sections being “GNU General Public License” and “GNU Free
  882. Documentation License”, with no Front-Cover Texts, and with no
  883. Back-Cover Texts.  A copy of the license is included in the section
  884. entitled “GNU Free Documentation License”. 
  885. </blockquote>
  886.  
  887. <!-- #### Maybe we should wrap these licenses in ifinfo?  Stallman says -->
  888. <!-- that the GFDL needs to be present in the manual, and to me it would -->
  889. <!-- suck to include the license for the manual and not the license for -->
  890. <!-- the program. -->
  891. <p>The full texts of the GNU General Public License and of the GNU Free
  892. Documentation License are available below.
  893.  
  894. <ul class="menu">
  895. <li><a accesskey="1" href="#GNU-General-Public-License">GNU General Public License</a>:  GNU GPL
  896. <li><a accesskey="2" href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>:  GNU FDL
  897. </ul>
  898.  
  899. <div class="node">
  900. <p><hr>
  901. <a name="GNU-General-Public-License"></a>
  902. Next: <a rel="next" accesskey="n" href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>,
  903. Previous: <a rel="previous" accesskey="p" href="#Copying">Copying</a>,
  904. Up: <a rel="up" accesskey="u" href="#Copying">Copying</a>
  905.  
  906. </div>
  907.  
  908. <h3 class="section">8.1 GNU General Public License</h3>
  909.  
  910. <div align="center">Version 2, June 1991</div>
  911.    <p><a name="index-GPL_002c-GNU-General-Public-License-220"></a>
  912. <pre class="display">     Copyright © 1989, 1991 Free Software Foundation, Inc.
  913.      675 Mass Ave, Cambridge, MA 02139, USA
  914.      
  915.      Everyone is permitted to copy and distribute verbatim copies
  916.      of this license document, but changing it is not allowed.
  917. </pre>
  918.    <h3 class="unnumberedsec">Preamble</h3>
  919.  
  920. <p>The licenses for most software are designed to take away your
  921. freedom to share and change it.  By contrast, the GNU General Public
  922. License is intended to guarantee your freedom to share and change free
  923. software—to make sure the software is free for all its users.  This
  924. General Public License applies to most of the Free Software
  925. Foundation's software and to any other program whose authors commit to
  926. using it.  (Some other Free Software Foundation software is covered by
  927. the GNU Library General Public License instead.)  You can apply it to
  928. your programs, too.
  929.  
  930.    <p>When we speak of free software, we are referring to freedom, not
  931. price.  Our General Public Licenses are designed to make sure that you
  932. have the freedom to distribute copies of free software (and charge for
  933. this service if you wish), that you receive source code or can get it
  934. if you want it, that you can change the software or use pieces of it
  935. in new free programs; and that you know you can do these things.
  936.  
  937.    <p>To protect your rights, we need to make restrictions that forbid
  938. anyone to deny you these rights or to ask you to surrender the rights. 
  939. These restrictions translate to certain responsibilities for you if you
  940. distribute copies of the software, or if you modify it.
  941.  
  942.    <p>For example, if you distribute copies of such a program, whether
  943. gratis or for a fee, you must give the recipients all the rights that
  944. you have.  You must make sure that they, too, receive or can get the
  945. source code.  And you must show them these terms so they know their
  946. rights.
  947.  
  948.    <p>We protect your rights with two steps: (1) copyright the software, and
  949. (2) offer you this license which gives you legal permission to copy,
  950. distribute and/or modify the software.
  951.  
  952.    <p>Also, for each author's protection and ours, we want to make certain
  953. that everyone understands that there is no warranty for this free
  954. software.  If the software is modified by someone else and passed on, we
  955. want its recipients to know that what they have is not the original, so
  956. that any problems introduced by others will not reflect on the original
  957. authors' reputations.
  958.  
  959.    <p>Finally, any free program is threatened constantly by software
  960. patents.  We wish to avoid the danger that redistributors of a free
  961. program will individually obtain patent licenses, in effect making the
  962. program proprietary.  To prevent this, we have made it clear that any
  963. patent must be licensed for everyone's free use or not licensed at all.
  964.  
  965.    <p>The precise terms and conditions for copying, distribution and
  966. modification follow.
  967.  
  968.      <ol type=1 start=1>
  969. <li>This License applies to any program or other work which contains
  970. a notice placed by the copyright holder saying it may be distributed
  971. under the terms of this General Public License.  The “Program”, below,
  972. refers to any such program or work, and a “work based on the Program”
  973. means either the Program or any derivative work under copyright law:
  974. that is to say, a work containing the Program or a portion of it,
  975. either verbatim or with modifications and/or translated into another
  976. language.  (Hereinafter, translation is included without limitation in
  977. the term “modification”.)  Each licensee is addressed as “you”.
  978.  
  979.      <p>Activities other than copying, distribution and modification are not
  980. covered by this License; they are outside its scope.  The act of
  981. running the Program is not restricted, and the output from the Program
  982. is covered only if its contents constitute a work based on the
  983. Program (independent of having been made by running the Program). 
  984. Whether that is true depends on what the Program does.
  985.  
  986.      <li>You may copy and distribute verbatim copies of the Program's
  987. source code as you receive it, in any medium, provided that you
  988. conspicuously and appropriately publish on each copy an appropriate
  989. copyright notice and disclaimer of warranty; keep intact all the
  990. notices that refer to this License and to the absence of any warranty;
  991. and give any other recipients of the Program a copy of this License
  992. along with the Program.
  993.  
  994.      <p>You may charge a fee for the physical act of transferring a copy, and
  995. you may at your option offer warranty protection in exchange for a fee.
  996.  
  997.      <li>You may modify your copy or copies of the Program or any portion
  998. of it, thus forming a work based on the Program, and copy and
  999. distribute such modifications or work under the terms of Section 1
  1000. above, provided that you also meet all of these conditions:
  1001.  
  1002.           <ol type=a start=1>
  1003. <li>You must cause the modified files to carry prominent notices
  1004. stating that you changed the files and the date of any change.
  1005.  
  1006.           <li>You must cause any work that you distribute or publish, that in
  1007. whole or in part contains or is derived from the Program or any
  1008. part thereof, to be licensed as a whole at no charge to all third
  1009. parties under the terms of this License.
  1010.  
  1011.           <li>If the modified program normally reads commands interactively
  1012. when run, you must cause it, when started running for such
  1013. interactive use in the most ordinary way, to print or display an
  1014. announcement including an appropriate copyright notice and a
  1015. notice that there is no warranty (or else, saying that you provide
  1016. a warranty) and that users may redistribute the program under
  1017. these conditions, and telling the user how to view a copy of this
  1018. License.  (Exception: if the Program itself is interactive but
  1019. does not normally print such an announcement, your work based on
  1020. the Program is not required to print an announcement.)
  1021.           </ol>
  1022.  
  1023.      <p>These requirements apply to the modified work as a whole.  If
  1024. identifiable sections of that work are not derived from the Program,
  1025. and can be reasonably considered independent and separate works in
  1026. themselves, then this License, and its terms, do not apply to those
  1027. sections when you distribute them as separate works.  But when you
  1028. distribute the same sections as part of a whole which is a work based
  1029. on the Program, the distribution of the whole must be on the terms of
  1030. this License, whose permissions for other licensees extend to the
  1031. entire whole, and thus to each and every part regardless of who wrote it.
  1032.  
  1033.      <p>Thus, it is not the intent of this section to claim rights or contest
  1034. your rights to work written entirely by you; rather, the intent is to
  1035. exercise the right to control the distribution of derivative or
  1036. collective works based on the Program.
  1037.  
  1038.      <p>In addition, mere aggregation of another work not based on the Program
  1039. with the Program (or with a work based on the Program) on a volume of
  1040. a storage or distribution medium does not bring the other work under
  1041. the scope of this License.
  1042.  
  1043.      <li>You may copy and distribute the Program (or a work based on it,
  1044. under Section 2) in object code or executable form under the terms of
  1045. Sections 1 and 2 above provided that you also do one of the following:
  1046.  
  1047.           <ol type=a start=1>
  1048. <li>Accompany it with the complete corresponding machine-readable
  1049. source code, which must be distributed under the terms of Sections
  1050. 1 and 2 above on a medium customarily used for software interchange; or,
  1051.  
  1052.           <li>Accompany it with a written offer, valid for at least three
  1053. years, to give any third party, for a charge no more than your
  1054. cost of physically performing source distribution, a complete
  1055. machine-readable copy of the corresponding source code, to be
  1056. distributed under the terms of Sections 1 and 2 above on a medium
  1057. customarily used for software interchange; or,
  1058.  
  1059.           <li>Accompany it with the information you received as to the offer
  1060. to distribute corresponding source code.  (This alternative is
  1061. allowed only for noncommercial distribution and only if you
  1062. received the program in object code or executable form with such
  1063. an offer, in accord with Subsection b above.)
  1064.           </ol>
  1065.  
  1066.      <p>The source code for a work means the preferred form of the work for
  1067. making modifications to it.  For an executable work, complete source
  1068. code means all the source code for all modules it contains, plus any
  1069. associated interface definition files, plus the scripts used to
  1070. control compilation and installation of the executable.  However, as a
  1071. special exception, the source code distributed need not include
  1072. anything that is normally distributed (in either source or binary
  1073. form) with the major components (compiler, kernel, and so on) of the
  1074. operating system on which the executable runs, unless that component
  1075. itself accompanies the executable.
  1076.  
  1077.      <p>If distribution of executable or object code is made by offering
  1078. access to copy from a designated place, then offering equivalent
  1079. access to copy the source code from the same place counts as
  1080. distribution of the source code, even though third parties are not
  1081. compelled to copy the source along with the object code.
  1082.  
  1083.      <li>You may not copy, modify, sublicense, or distribute the Program
  1084. except as expressly provided under this License.  Any attempt
  1085. otherwise to copy, modify, sublicense or distribute the Program is
  1086. void, and will automatically terminate your rights under this License. 
  1087. However, parties who have received copies, or rights, from you under
  1088. this License will not have their licenses terminated so long as such
  1089. parties remain in full compliance.
  1090.  
  1091.      <li>You are not required to accept this License, since you have not
  1092. signed it.  However, nothing else grants you permission to modify or
  1093. distribute the Program or its derivative works.  These actions are
  1094. prohibited by law if you do not accept this License.  Therefore, by
  1095. modifying or distributing the Program (or any work based on the
  1096. Program), you indicate your acceptance of this License to do so, and
  1097. all its terms and conditions for copying, distributing or modifying
  1098. the Program or works based on it.
  1099.  
  1100.      <li>Each time you redistribute the Program (or any work based on the
  1101. Program), the recipient automatically receives a license from the
  1102. original licensor to copy, distribute or modify the Program subject to
  1103. these terms and conditions.  You may not impose any further
  1104. restrictions on the recipients' exercise of the rights granted herein. 
  1105. You are not responsible for enforcing compliance by third parties to
  1106. this License.
  1107.  
  1108.      <li>If, as a consequence of a court judgment or allegation of patent
  1109. infringement or for any other reason (not limited to patent issues),
  1110. conditions are imposed on you (whether by court order, agreement or
  1111. otherwise) that contradict the conditions of this License, they do not
  1112. excuse you from the conditions of this License.  If you cannot
  1113. distribute so as to satisfy simultaneously your obligations under this
  1114. License and any other pertinent obligations, then as a consequence you
  1115. may not distribute the Program at all.  For example, if a patent
  1116. license would not permit royalty-free redistribution of the Program by
  1117. all those who receive copies directly or indirectly through you, then
  1118. the only way you could satisfy both it and this License would be to
  1119. refrain entirely from distribution of the Program.
  1120.  
  1121.      <p>If any portion of this section is held invalid or unenforceable under
  1122. any particular circumstance, the balance of the section is intended to
  1123. apply and the section as a whole is intended to apply in other
  1124. circumstances.
  1125.  
  1126.      <p>It is not the purpose of this section to induce you to infringe any
  1127. patents or other property right claims or to contest validity of any
  1128. such claims; this section has the sole purpose of protecting the
  1129. integrity of the free software distribution system, which is
  1130. implemented by public license practices.  Many people have made
  1131. generous contributions to the wide range of software distributed
  1132. through that system in reliance on consistent application of that
  1133. system; it is up to the author/donor to decide if he or she is willing
  1134. to distribute software through any other system and a licensee cannot
  1135. impose that choice.
  1136.  
  1137.      <p>This section is intended to make thoroughly clear what is believed to
  1138. be a consequence of the rest of this License.
  1139.  
  1140.      <li>If the distribution and/or use of the Program is restricted in
  1141. certain countries either by patents or by copyrighted interfaces, the
  1142. original copyright holder who places the Program under this License
  1143. may add an explicit geographical distribution limitation excluding
  1144. those countries, so that distribution is permitted only in or among
  1145. countries not thus excluded.  In such case, this License incorporates
  1146. the limitation as if written in the body of this License.
  1147.  
  1148.      <li>The Free Software Foundation may publish revised and/or new versions
  1149. of the General Public License from time to time.  Such new versions will
  1150. be similar in spirit to the present version, but may differ in detail to
  1151. address new problems or concerns.
  1152.  
  1153.      <p>Each version is given a distinguishing version number.  If the Program
  1154. specifies a version number of this License which applies to it and “any
  1155. later version”, you have the option of following the terms and conditions
  1156. either of that version or of any later version published by the Free
  1157. Software Foundation.  If the Program does not specify a version number of
  1158. this License, you may choose any version ever published by the Free Software
  1159. Foundation.
  1160.  
  1161.      <li>If you wish to incorporate parts of the Program into other free
  1162. programs whose distribution conditions are different, write to the author
  1163. to ask for permission.  For software which is copyrighted by the Free
  1164. Software Foundation, write to the Free Software Foundation; we sometimes
  1165. make exceptions for this.  Our decision will be guided by the two goals
  1166. of preserving the free status of all derivatives of our free software and
  1167. of promoting the sharing and reuse of software generally.
  1168.  
  1169.      <p><a name="index-no-warranty-221"></a>
  1170. <li>BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  1171. FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
  1172. OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  1173. PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
  1174. OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  1175. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
  1176. TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  1177. PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
  1178. REPAIR OR CORRECTION.
  1179.  
  1180.      <li>IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  1181. WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  1182. REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  1183. INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
  1184. OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
  1185. TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
  1186. YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  1187. PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
  1188. POSSIBILITY OF SUCH DAMAGES.
  1189.         </ol>
  1190.  
  1191. <h3 class="unnumberedsec">How to Apply These Terms to Your New Programs</h3>
  1192.  
  1193. <p>If you develop a new program, and you want it to be of the greatest
  1194. possible use to the public, the best way to achieve this is to make it
  1195. free software which everyone can redistribute and change under these terms.
  1196.  
  1197.    <p>To do so, attach the following notices to the program.  It is safest
  1198. to attach them to the start of each source file to most effectively
  1199. convey the exclusion of warranty; and each file should have at least
  1200. the “copyright” line and a pointer to where the full notice is found.
  1201.  
  1202. <pre class="smallexample">     <var>one line to give the program's name and an idea of what it does.</var>
  1203.      Copyright (C) 19<var>yy</var>  <var>name of author</var>
  1204.      
  1205.      This program is free software; you can redistribute it and/or
  1206.      modify it under the terms of the GNU General Public License
  1207.      as published by the Free Software Foundation; either version 2
  1208.      of the License, or (at your option) any later version.
  1209.      
  1210.      This program is distributed in the hope that it will be useful,
  1211.      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1212.      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1213.      GNU General Public License for more details.
  1214.      
  1215.      You should have received a copy of the GNU General Public License
  1216.      along with this program; if not, write to the Free Software
  1217.      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1218. </pre>
  1219.    <p>Also add information on how to contact you by electronic and paper mail.
  1220.  
  1221.    <p>If the program is interactive, make it output a short notice like this
  1222. when it starts in an interactive mode:
  1223.  
  1224. <pre class="smallexample">     Gnomovision version 69, Copyright (C) 19<var>yy</var> <var>name of author</var>
  1225.      Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
  1226.      type `show w'.  This is free software, and you are welcome
  1227.      to redistribute it under certain conditions; type `show c'
  1228.      for details.
  1229. </pre>
  1230.    <p>The hypothetical commands `<samp><span class="samp">show w</span></samp>' and `<samp><span class="samp">show c</span></samp>' should show
  1231. the appropriate parts of the General Public License.  Of course, the
  1232. commands you use may be called something other than `<samp><span class="samp">show w</span></samp>' and
  1233. `<samp><span class="samp">show c</span></samp>'; they could even be mouse-clicks or menu items—whatever
  1234. suits your program.
  1235.  
  1236.    <p>You should also get your employer (if you work as a programmer) or your
  1237. school, if any, to sign a “copyright disclaimer” for the program, if
  1238. necessary.  Here is a sample; alter the names:
  1239.  
  1240. <pre class="smallexample">     Yoyodyne, Inc., hereby disclaims all copyright
  1241.      interest in the program `Gnomovision'
  1242.      (which makes passes at compilers) written
  1243.      by James Hacker.
  1244.      
  1245.      <var>signature of Ty Coon</var>, 1 April 1989
  1246.      Ty Coon, President of Vice
  1247. </pre>
  1248.    <p>This General Public License does not permit incorporating your program into
  1249. proprietary programs.  If your program is a subroutine library, you may
  1250. consider it more useful to permit linking proprietary applications with the
  1251. library.  If this is what you want to do, use the GNU Library General
  1252. Public License instead of this License.
  1253.  
  1254. <div class="node">
  1255. <p><hr>
  1256. <a name="GNU-Free-Documentation-License"></a>
  1257. Next: <a rel="next" accesskey="n" href="#Concept-Index">Concept Index</a>,
  1258. Previous: <a rel="previous" accesskey="p" href="#GNU-General-Public-License">GNU General Public License</a>,
  1259. Up: <a rel="up" accesskey="u" href="#Copying">Copying</a>
  1260.  
  1261. </div>
  1262.  
  1263. <h3 class="section">8.2 GNU Free Documentation License</h3>
  1264.  
  1265. <div align="center">Version 1.1, March 2000</div>
  1266.    <p><a name="index-FDL_002c-GNU-Free-Documentation-License-222"></a>
  1267. <pre class="display">     Copyright (C) 2000  Free Software Foundation, Inc.
  1268.      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  1269.      
  1270.      Everyone is permitted to copy and distribute verbatim copies
  1271.      of this license document, but changing it is not allowed.
  1272. </pre>
  1273.    <pre class="sp">
  1274.  
  1275. </pre>
  1276.      <ol type=1 start=0>
  1277. <li>PREAMBLE
  1278.  
  1279.      <p>The purpose of this License is to make a manual, textbook, or other
  1280. written document “free” in the sense of freedom: to assure everyone
  1281. the effective freedom to copy and redistribute it, with or without
  1282. modifying it, either commercially or noncommercially.  Secondarily,
  1283. this License preserves for the author and publisher a way to get
  1284. credit for their work, while not being considered responsible for
  1285. modifications made by others.
  1286.  
  1287.      <p>This License is a kind of “copyleft”, which means that derivative
  1288. works of the document must themselves be free in the same sense.  It
  1289. complements the GNU General Public License, which is a copyleft
  1290. license designed for free software.
  1291.  
  1292.      <p>We have designed this License in order to use it for manuals for free
  1293. software, because free software needs free documentation: a free
  1294. program should come with manuals providing the same freedoms that the
  1295. software does.  But this License is not limited to software manuals;
  1296. it can be used for any textual work, regardless of subject matter or
  1297. whether it is published as a printed book.  We recommend this License
  1298. principally for works whose purpose is instruction or reference.
  1299.  
  1300.      <pre class="sp">
  1301.      
  1302.      </pre>
  1303.      <li>APPLICABILITY AND DEFINITIONS
  1304.  
  1305.      <p>This License applies to any manual or other work that contains a
  1306. notice placed by the copyright holder saying it can be distributed
  1307. under the terms of this License.  The “Document”, below, refers to any
  1308. such manual or work.  Any member of the public is a licensee, and is
  1309. addressed as “you”.
  1310.  
  1311.      <p>A “Modified Version” of the Document means any work containing the
  1312. Document or a portion of it, either copied verbatim, or with
  1313. modifications and/or translated into another language.
  1314.  
  1315.      <p>A “Secondary Section” is a named appendix or a front-matter section of
  1316. the Document that deals exclusively with the relationship of the
  1317. publishers or authors of the Document to the Document's overall subject
  1318. (or to related matters) and contains nothing that could fall directly
  1319. within that overall subject.  (For example, if the Document is in part a
  1320. textbook of mathematics, a Secondary Section may not explain any
  1321. mathematics.)  The relationship could be a matter of historical
  1322. connection with the subject or with related matters, or of legal,
  1323. commercial, philosophical, ethical or political position regarding
  1324. them.
  1325.  
  1326.      <p>The “Invariant Sections” are certain Secondary Sections whose titles
  1327. are designated, as being those of Invariant Sections, in the notice
  1328. that says that the Document is released under this License.
  1329.  
  1330.      <p>The “Cover Texts” are certain short passages of text that are listed,
  1331. as Front-Cover Texts or Back-Cover Texts, in the notice that says that
  1332. the Document is released under this License.
  1333.  
  1334.      <p>A “Transparent” copy of the Document means a machine-readable copy,
  1335. represented in a format whose specification is available to the
  1336. general public, whose contents can be viewed and edited directly and
  1337. straightforwardly with generic text editors or (for images composed of
  1338. pixels) generic paint programs or (for drawings) some widely available
  1339. drawing editor, and that is suitable for input to text formatters or
  1340. for automatic translation to a variety of formats suitable for input
  1341. to text formatters.  A copy made in an otherwise Transparent file
  1342. format whose markup has been designed to thwart or discourage
  1343. subsequent modification by readers is not Transparent.  A copy that is
  1344. not “Transparent” is called “Opaque”.
  1345.  
  1346.      <p>Examples of suitable formats for Transparent copies include plain
  1347. ASCII without markup, Texinfo input format, LaTeX input format, SGML
  1348. or XML using a publicly available DTD, and standard-conforming simple
  1349. HTML designed for human modification.  Opaque formats include
  1350. PostScript, PDF, proprietary formats that can be read and edited only
  1351. by proprietary word processors, SGML or XML for which the DTD and/or
  1352. processing tools are not generally available, and the
  1353. machine-generated HTML produced by some word processors for output
  1354. purposes only.
  1355.  
  1356.      <p>The “Title Page” means, for a printed book, the title page itself,
  1357. plus such following pages as are needed to hold, legibly, the material
  1358. this License requires to appear in the title page.  For works in
  1359. formats which do not have any title page as such, “Title Page” means
  1360. the text near the most prominent appearance of the work's title,
  1361. preceding the beginning of the body of the text.
  1362.      <pre class="sp">
  1363.      
  1364.      </pre>
  1365.      <li>VERBATIM COPYING
  1366.  
  1367.      <p>You may copy and distribute the Document in any medium, either
  1368. commercially or noncommercially, provided that this License, the
  1369. copyright notices, and the license notice saying this License applies
  1370. to the Document are reproduced in all copies, and that you add no other
  1371. conditions whatsoever to those of this License.  You may not use
  1372. technical measures to obstruct or control the reading or further
  1373. copying of the copies you make or distribute.  However, you may accept
  1374. compensation in exchange for copies.  If you distribute a large enough
  1375. number of copies you must also follow the conditions in section 3.
  1376.  
  1377.      <p>You may also lend copies, under the same conditions stated above, and
  1378. you may publicly display copies.
  1379.      <pre class="sp">
  1380.      
  1381.      </pre>
  1382.      <li>COPYING IN QUANTITY
  1383.  
  1384.      <p>If you publish printed copies of the Document numbering more than 100,
  1385. and the Document's license notice requires Cover Texts, you must enclose
  1386. the copies in covers that carry, clearly and legibly, all these Cover
  1387. Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
  1388. the back cover.  Both covers must also clearly and legibly identify
  1389. you as the publisher of these copies.  The front cover must present
  1390. the full title with all words of the title equally prominent and
  1391. visible.  You may add other material on the covers in addition. 
  1392. Copying with changes limited to the covers, as long as they preserve
  1393. the title of the Document and satisfy these conditions, can be treated
  1394. as verbatim copying in other respects.
  1395.  
  1396.      <p>If the required texts for either cover are too voluminous to fit
  1397. legibly, you should put the first ones listed (as many as fit
  1398. reasonably) on the actual cover, and continue the rest onto adjacent
  1399. pages.
  1400.  
  1401.      <p>If you publish or distribute Opaque copies of the Document numbering
  1402. more than 100, you must either include a machine-readable Transparent
  1403. copy along with each Opaque copy, or state in or with each Opaque copy
  1404. a publicly-accessible computer-network location containing a complete
  1405. Transparent copy of the Document, free of added material, which the
  1406. general network-using public has access to download anonymously at no
  1407. charge using public-standard network protocols.  If you use the latter
  1408. option, you must take reasonably prudent steps, when you begin
  1409. distribution of Opaque copies in quantity, to ensure that this
  1410. Transparent copy will remain thus accessible at the stated location
  1411. until at least one year after the last time you distribute an Opaque
  1412. copy (directly or through your agents or retailers) of that edition to
  1413. the public.
  1414.  
  1415.      <p>It is requested, but not required, that you contact the authors of the
  1416. Document well before redistributing any large number of copies, to give
  1417. them a chance to provide you with an updated version of the Document.
  1418.      <pre class="sp">
  1419.      
  1420.      </pre>
  1421.      <li>MODIFICATIONS
  1422.  
  1423.      <p>You may copy and distribute a Modified Version of the Document under
  1424. the conditions of sections 2 and 3 above, provided that you release
  1425. the Modified Version under precisely this License, with the Modified
  1426. Version filling the role of the Document, thus licensing distribution
  1427. and modification of the Modified Version to whoever possesses a copy
  1428. of it.  In addition, you must do these things in the Modified Version:
  1429.  
  1430.      <p>A. Use in the Title Page (and on the covers, if any) a title distinct
  1431.    from that of the Document, and from those of previous versions
  1432.    (which should, if there were any, be listed in the History section
  1433.    of the Document).  You may use the same title as a previous version
  1434.    if the original publisher of that version gives permission.<br>
  1435. B. List on the Title Page, as authors, one or more persons or entities
  1436.    responsible for authorship of the modifications in the Modified
  1437.    Version, together with at least five of the principal authors of the
  1438.    Document (all of its principal authors, if it has less than five).<br>
  1439. C. State on the Title page the name of the publisher of the
  1440.    Modified Version, as the publisher.<br>
  1441. D. Preserve all the copyright notices of the Document.<br>
  1442. E. Add an appropriate copyright notice for your modifications
  1443.    adjacent to the other copyright notices.<br>
  1444. F. Include, immediately after the copyright notices, a license notice
  1445.    giving the public permission to use the Modified Version under the
  1446.    terms of this License, in the form shown in the Addendum below.<br>
  1447. G. Preserve in that license notice the full lists of Invariant Sections
  1448.    and required Cover Texts given in the Document's license notice.<br>
  1449. H. Include an unaltered copy of this License.<br>
  1450. I. Preserve the section entitled “History”, and its title, and add to
  1451.    it an item stating at least the title, year, new authors, and
  1452.    publisher of the Modified Version as given on the Title Page.  If
  1453.    there is no section entitled “History” in the Document, create one
  1454.    stating the title, year, authors, and publisher of the Document as
  1455.    given on its Title Page, then add an item describing the Modified
  1456.    Version as stated in the previous sentence.<br>
  1457. J. Preserve the network location, if any, given in the Document for
  1458.    public access to a Transparent copy of the Document, and likewise
  1459.    the network locations given in the Document for previous versions
  1460.    it was based on.  These may be placed in the “History” section. 
  1461.    You may omit a network location for a work that was published at
  1462.    least four years before the Document itself, or if the original
  1463.    publisher of the version it refers to gives permission.<br>
  1464. K. In any section entitled “Acknowledgements” or “Dedications”,
  1465.    preserve the section's title, and preserve in the section all the
  1466.    substance and tone of each of the contributor acknowledgements
  1467.    and/or dedications given therein.<br>
  1468. L. Preserve all the Invariant Sections of the Document,
  1469.    unaltered in their text and in their titles.  Section numbers
  1470.    or the equivalent are not considered part of the section titles.<br>
  1471. M. Delete any section entitled “Endorsements”.  Such a section
  1472.    may not be included in the Modified Version.<br>
  1473. N. Do not retitle any existing section as “Endorsements”
  1474.    or to conflict in title with any Invariant Section.<br>
  1475.      <pre class="sp">
  1476.      
  1477.      </pre>
  1478.      If the Modified Version includes new front-matter sections or
  1479. appendices that qualify as Secondary Sections and contain no material
  1480. copied from the Document, you may at your option designate some or all
  1481. of these sections as invariant.  To do this, add their titles to the
  1482. list of Invariant Sections in the Modified Version's license notice. 
  1483. These titles must be distinct from any other section titles.
  1484.  
  1485.      <p>You may add a section entitled “Endorsements”, provided it contains
  1486. nothing but endorsements of your Modified Version by various
  1487. parties–for example, statements of peer review or that the text has
  1488. been approved by an organization as the authoritative definition of a
  1489. standard.
  1490.  
  1491.      <p>You may add a passage of up to five words as a Front-Cover Text, and a
  1492. passage of up to 25 words as a Back-Cover Text, to the end of the list
  1493. of Cover Texts in the Modified Version.  Only one passage of
  1494. Front-Cover Text and one of Back-Cover Text may be added by (or
  1495. through arrangements made by) any one entity.  If the Document already
  1496. includes a cover text for the same cover, previously added by you or
  1497. by arrangement made by the same entity you are acting on behalf of,
  1498. you may not add another; but you may replace the old one, on explicit
  1499. permission from the previous publisher that added the old one.
  1500.  
  1501.      <p>The author(s) and publisher(s) of the Document do not by this License
  1502. give permission to use their names for publicity for or to assert or
  1503. imply endorsement of any Modified Version.
  1504.      <pre class="sp">
  1505.      
  1506.      </pre>
  1507.      <li>COMBINING DOCUMENTS
  1508.  
  1509.      <p>You may combine the Document with other documents released under this
  1510. License, under the terms defined in section 4 above for modified
  1511. versions, provided that you include in the combination all of the
  1512. Invariant Sections of all of the original documents, unmodified, and
  1513. list them all as Invariant Sections of your combined work in its
  1514. license notice.
  1515.  
  1516.      <p>The combined work need only contain one copy of this License, and
  1517. multiple identical Invariant Sections may be replaced with a single
  1518. copy.  If there are multiple Invariant Sections with the same name but
  1519. different contents, make the title of each such section unique by
  1520. adding at the end of it, in parentheses, the name of the original
  1521. author or publisher of that section if known, or else a unique number. 
  1522. Make the same adjustment to the section titles in the list of
  1523. Invariant Sections in the license notice of the combined work.
  1524.  
  1525.      <p>In the combination, you must combine any sections entitled “History”
  1526. in the various original documents, forming one section entitled
  1527. “History”; likewise combine any sections entitled “Acknowledgements”,
  1528. and any sections entitled “Dedications”.  You must delete all sections
  1529. entitled “Endorsements.”
  1530.      <pre class="sp">
  1531.      
  1532.      </pre>
  1533.      <li>COLLECTIONS OF DOCUMENTS
  1534.  
  1535.      <p>You may make a collection consisting of the Document and other documents
  1536. released under this License, and replace the individual copies of this
  1537. License in the various documents with a single copy that is included in
  1538. the collection, provided that you follow the rules of this License for
  1539. verbatim copying of each of the documents in all other respects.
  1540.  
  1541.      <p>You may extract a single document from such a collection, and distribute
  1542. it individually under this License, provided you insert a copy of this
  1543. License into the extracted document, and follow this License in all
  1544. other respects regarding verbatim copying of that document.
  1545.      <pre class="sp">
  1546.      
  1547.      </pre>
  1548.      <li>AGGREGATION WITH INDEPENDENT WORKS
  1549.  
  1550.      <p>A compilation of the Document or its derivatives with other separate
  1551. and independent documents or works, in or on a volume of a storage or
  1552. distribution medium, does not as a whole count as a Modified Version
  1553. of the Document, provided no compilation copyright is claimed for the
  1554. compilation.  Such a compilation is called an “aggregate”, and this
  1555. License does not apply to the other self-contained works thus compiled
  1556. with the Document, on account of their being thus compiled, if they
  1557. are not themselves derivative works of the Document.
  1558.  
  1559.      <p>If the Cover Text requirement of section 3 is applicable to these
  1560. copies of the Document, then if the Document is less than one quarter
  1561. of the entire aggregate, the Document's Cover Texts may be placed on
  1562. covers that surround only the Document within the aggregate. 
  1563. Otherwise they must appear on covers around the whole aggregate.
  1564.      <pre class="sp">
  1565.      
  1566.      </pre>
  1567.      <li>TRANSLATION
  1568.  
  1569.      <p>Translation is considered a kind of modification, so you may
  1570. distribute translations of the Document under the terms of section 4. 
  1571. Replacing Invariant Sections with translations requires special
  1572. permission from their copyright holders, but you may include
  1573. translations of some or all Invariant Sections in addition to the
  1574. original versions of these Invariant Sections.  You may include a
  1575. translation of this License provided that you also include the
  1576. original English version of this License.  In case of a disagreement
  1577. between the translation and the original English version of this
  1578. License, the original English version will prevail.
  1579.      <pre class="sp">
  1580.      
  1581.      </pre>
  1582.      <li>TERMINATION
  1583.  
  1584.      <p>You may not copy, modify, sublicense, or distribute the Document except
  1585. as expressly provided for under this License.  Any other attempt to
  1586. copy, modify, sublicense or distribute the Document is void, and will
  1587. automatically terminate your rights under this License.  However,
  1588. parties who have received copies, or rights, from you under this
  1589. License will not have their licenses terminated so long as such
  1590. parties remain in full compliance.
  1591.      <pre class="sp">
  1592.      
  1593.      </pre>
  1594.      <li>FUTURE REVISIONS OF THIS LICENSE
  1595.  
  1596.      <p>The Free Software Foundation may publish new, revised versions
  1597. of the GNU Free Documentation License from time to time.  Such new
  1598. versions will be similar in spirit to the present version, but may
  1599. differ in detail to address new problems or concerns.  See
  1600. http://www.gnu.org/copyleft/.
  1601.  
  1602.      <p>Each version of the License is given a distinguishing version number. 
  1603. If the Document specifies that a particular numbered version of this
  1604. License “or any later version” applies to it, you have the option of
  1605. following the terms and conditions either of that specified version or
  1606. of any later version that has been published (not as a draft) by the
  1607. Free Software Foundation.  If the Document does not specify a version
  1608. number of this License, you may choose any version ever published (not
  1609. as a draft) by the Free Software Foundation.
  1610.  
  1611.         </ol>
  1612.  
  1613. <h3 class="unnumberedsec">ADDENDUM: How to use this License for your documents</h3>
  1614.  
  1615. <p>To use this License in a document you have written, include a copy of
  1616. the License in the document and put the following copyright and
  1617. license notices just after the title page:
  1618.  
  1619. <pre class="smallexample">     
  1620.        Copyright (C)  <var>year</var>  <var>your name</var>.
  1621.        Permission is granted to copy, distribute and/or modify this document
  1622.        under the terms of the GNU Free Documentation License, Version 1.1
  1623.        or any later version published by the Free Software Foundation;
  1624.        with the Invariant Sections being <var>list their titles</var>, with the
  1625.        Front-Cover Texts being <var>list</var>, and with the Back-Cover Texts being <var>list</var>.
  1626.        A copy of the license is included in the section entitled ``GNU
  1627.        Free Documentation License''.
  1628. </pre>
  1629.    <p>If you have no Invariant Sections, write “with no Invariant Sections”
  1630. instead of saying which ones are invariant.  If you have no
  1631. Front-Cover Texts, write “no Front-Cover Texts” instead of
  1632. “Front-Cover Texts being <var>list</var>”; likewise for Back-Cover Texts.
  1633.  
  1634.    <p>If your document contains nontrivial examples of program code, we
  1635. recommend releasing these examples in parallel under your choice of
  1636. free software license, such as the GNU General Public License,
  1637. to permit their use in free software.
  1638.  
  1639. <div class="node">
  1640. <p><hr>
  1641. <a name="Concept-Index"></a>
  1642. Next: <a rel="next" accesskey="n" href="#Index">Index</a>,
  1643. Previous: <a rel="previous" accesskey="p" href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>,
  1644. Up: <a rel="up" accesskey="u" href="#Top">Top</a>
  1645.  
  1646. </div>
  1647.  
  1648. <h2 class="unnumbered">Concept Index</h2>
  1649.  
  1650. <p>This is a general index of all issues discussed in this manual, with the
  1651. exception of the <samp><span class="command">grep</span></samp> commands and command-line options.
  1652.  
  1653. <ul class="index-cp" compact>
  1654. <li><a href="#index-after-context-39">after context</a>: <a href="#Invoking">Invoking</a></li>
  1655. <li><a href="#index-alphabetic-characters-185">alphabetic characters</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1656. <li><a href="#index-alphanumeric-characters-183">alphanumeric characters</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1657. <li><a href="#index-anchoring-210">anchoring</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1658. <li><a href="#index-asterisk-165">asterisk</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1659. <li><a href="#index-back_002dreference-211">back-reference</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1660. <li><a href="#index-backslash-209">backslash</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1661. <li><a href="#index-basic-regular-expressions-212">basic regular expressions</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1662. <li><a href="#index-before-context-43">before context</a>: <a href="#Invoking">Invoking</a></li>
  1663. <li><a href="#index-binary-files-57">binary files</a>: <a href="#Invoking">Invoking</a></li>
  1664. <li><a href="#index-binary-files_002c-DOS_002fWindows-105">binary files, DOS/Windows</a>: <a href="#Invoking">Invoking</a></li>
  1665. <li><a href="#index-blank-characters-187">blank characters</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1666. <li><a href="#index-braces_002c-one-argument-170">braces, one argument</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1667. <li><a href="#index-braces_002c-second-argument-omitted-173">braces, second argument omitted</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1668. <li><a href="#index-braces_002c-two-arguments-176">braces, two arguments</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1669. <li><a href="#index-bracket-expression-177">bracket expression</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1670. <li><a href="#index-Bugs_002c-reporting-218">Bugs, reporting</a>: <a href="#Reporting-Bugs">Reporting Bugs</a></li>
  1671. <li><a href="#index-byte-offset-60">byte offset</a>: <a href="#Invoking">Invoking</a></li>
  1672. <li><a href="#index-byte-offsets_002c-on-DOS_002fWindows-109">byte offsets, on DOS/Windows</a>: <a href="#Invoking">Invoking</a></li>
  1673. <li><a href="#index-case-insensitive-search-13">case insensitive search</a>: <a href="#Invoking">Invoking</a></li>
  1674. <li><a href="#index-case-insensitive-search_002c-obsolete-option-101">case insensitive search, obsolete option</a>: <a href="#Invoking">Invoking</a></li>
  1675. <li><a href="#index-changing-name-of-standard-input-76">changing name of standard input</a>: <a href="#Invoking">Invoking</a></li>
  1676. <li><a href="#index-character-class-178">character class</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1677. <li><a href="#index-character-classes-181">character classes</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1678. <li><a href="#index-character-type-126">character type</a>: <a href="#Invoking">Invoking</a></li>
  1679. <li><a href="#index-classes-of-characters-180">classes of characters</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1680. <li><a href="#index-context-47">context</a>: <a href="#Invoking">Invoking</a></li>
  1681. <li><a href="#index-context-lines_002c-after-match-40">context lines, after match</a>: <a href="#Invoking">Invoking</a></li>
  1682. <li><a href="#index-context-lines_002c-before-match-44">context lines, before match</a>: <a href="#Invoking">Invoking</a></li>
  1683. <li><a href="#index-control-characters-189">control characters</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1684. <li><a href="#index-Copying-219">Copying</a>: <a href="#Copying">Copying</a></li>
  1685. <li><a href="#index-counting-lines-4">counting lines</a>: <a href="#Invoking">Invoking</a></li>
  1686. <li><a href="#index-default-options-environment-variable-120">default options environment variable</a>: <a href="#Invoking">Invoking</a></li>
  1687. <li><a href="#index-device-search-63">device search</a>: <a href="#Invoking">Invoking</a></li>
  1688. <li><a href="#index-digit-characters-191">digit characters</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1689. <li><a href="#index-directory-search-66">directory search</a>: <a href="#Invoking">Invoking</a></li>
  1690. <li><a href="#index-DOS-byte-offsets-108">DOS byte offsets</a>: <a href="#Invoking">Invoking</a></li>
  1691. <li><a href="#index-DOS_002fWindows-binary-files-104">DOS/Windows binary files</a>: <a href="#Invoking">Invoking</a></li>
  1692. <li><a href="#index-dot-159">dot</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1693. <li><a href="#index-environment-variables-118">environment variables</a>: <a href="#Invoking">Invoking</a></li>
  1694. <li><a href="#index-exclude-files-95">exclude files</a>: <a href="#Invoking">Invoking</a></li>
  1695. <li><a href="#index-FAQ-about-_0040command_007bgrep_007d-usage-216">FAQ about <samp><span class="command">grep</span></samp> usage</a>: <a href="#Usage">Usage</a></li>
  1696. <li><a href="#index-FDL_002c-GNU-Free-Documentation-License-222">FDL, GNU Free Documentation License</a>: <a href="#GNU-Free-Documentation-License">GNU Free Documentation License</a></li>
  1697. <li><a href="#index-files-which-don_0027t-match-79">files which don't match</a>: <a href="#Invoking">Invoking</a></li>
  1698. <li><a href="#index-GPL_002c-GNU-General-Public-License-220">GPL, GNU General Public License</a>: <a href="#GNU-General-Public-License">GNU General Public License</a></li>
  1699. <li><a href="#index-graphic-characters-194">graphic characters</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1700. <li><a href="#index-hexadecimal-digits-208">hexadecimal digits</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1701. <li><a href="#index-highlight-markers-122">highlight markers</a>: <a href="#Invoking">Invoking</a></li>
  1702. <li><a href="#index-highlight_002c-color_002c-colour-49">highlight, color, colour</a>: <a href="#Invoking">Invoking</a></li>
  1703. <li><a href="#index-include-files-92">include files</a>: <a href="#Invoking">Invoking</a></li>
  1704. <li><a href="#index-interval-specifications-213">interval specifications</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1705. <li><a href="#index-invert-matching-32">invert matching</a>: <a href="#Invoking">Invoking</a></li>
  1706. <li><a href="#index-language-of-messages-138">language of messages</a>: <a href="#Invoking">Invoking</a></li>
  1707. <li><a href="#index-line-buffering-74">line buffering</a>: <a href="#Invoking">Invoking</a></li>
  1708. <li><a href="#index-line-numbering-19">line numbering</a>: <a href="#Invoking">Invoking</a></li>
  1709. <li><a href="#index-lower_002dcase-letters-196">lower-case letters</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1710. <li><a href="#index-match-sub_002dexpression-at-most-once-163">match sub-expression at most once</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1711. <li><a href="#index-match-sub_002dexpression-n-or-more-times-174">match sub-expression n or more times</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1712. <li><a href="#index-match-sub_002dexpression-n-times-171">match sub-expression n times</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1713. <li><a href="#index-match-sub_002dexpression-zero-or-more-times-166">match sub-expression zero or more times</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1714. <li><a href="#index-match-the-whole-line-36">match the whole line</a>: <a href="#Invoking">Invoking</a></li>
  1715. <li><a href="#index-matching-basic-regular-expressions-147">matching basic regular expressions</a>: <a href="#Grep-Programs">Grep Programs</a></li>
  1716. <li><a href="#index-matching-extended-regular-expressions-150">matching extended regular expressions</a>: <a href="#Grep-Programs">Grep Programs</a></li>
  1717. <li><a href="#index-matching-fixed-strings-153">matching fixed strings</a>: <a href="#Grep-Programs">Grep Programs</a></li>
  1718. <li><a href="#index-matching-Perl-regular-expressions-156">matching Perl regular expressions</a>: <a href="#Grep-Programs">Grep Programs</a></li>
  1719. <li><a href="#index-matching-whole-words-86">matching whole words</a>: <a href="#Invoking">Invoking</a></li>
  1720. <li><a href="#index-max_002dcount-99">max-count</a>: <a href="#Invoking">Invoking</a></li>
  1721. <li><a href="#index-memory-mapped-input-111">memory mapped input</a>: <a href="#Invoking">Invoking</a></li>
  1722. <li><a href="#index-message-language-139">message language</a>: <a href="#Invoking">Invoking</a></li>
  1723. <li><a href="#index-names-of-matching-files-16">names of matching files</a>: <a href="#Invoking">Invoking</a></li>
  1724. <li><a href="#index-national-language-support-127">national language support</a>: <a href="#Invoking">Invoking</a></li>
  1725. <li><a href="#index-NLS-128">NLS</a>: <a href="#Invoking">Invoking</a></li>
  1726. <li><a href="#index-no-filename-prefix-72">no filename prefix</a>: <a href="#Invoking">Invoking</a></li>
  1727. <li><a href="#index-no-warranty-221">no warranty</a>: <a href="#GNU-General-Public-License">GNU General Public License</a></li>
  1728. <li><a href="#index-numeric-characters-192">numeric characters</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1729. <li><a href="#index-only-matching-22">only matching</a>: <a href="#Invoking">Invoking</a></li>
  1730. <li><a href="#index-palindromes-217">palindromes</a>: <a href="#Usage">Usage</a></li>
  1731. <li><a href="#index-pattern-from-file-10">pattern from file</a>: <a href="#Invoking">Invoking</a></li>
  1732. <li><a href="#index-pattern-list-7">pattern list</a>: <a href="#Invoking">Invoking</a></li>
  1733. <li><a href="#index-period-160">period</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1734. <li><a href="#index-plus-sign-168">plus sign</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1735. <li><a href="#index-print-non_002dmatching-lines-33">print non-matching lines</a>: <a href="#Invoking">Invoking</a></li>
  1736. <li><a href="#index-printable-characters-198">printable characters</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1737. <li><a href="#index-punctuation-characters-200">punctuation characters</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1738. <li><a href="#index-question-mark-162">question mark</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1739. <li><a href="#index-quiet_002c-silent-26">quiet, silent</a>: <a href="#Invoking">Invoking</a></li>
  1740. <li><a href="#index-range-expression-179">range expression</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1741. <li><a href="#index-recursive-search-89">recursive search</a>: <a href="#Invoking">Invoking</a></li>
  1742. <li><a href="#index-regular-expressions-157">regular expressions</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1743. <li><a href="#index-searching-directory-trees-90">searching directory trees</a>: <a href="#Invoking">Invoking</a></li>
  1744. <li><a href="#index-Searching-for-a-pattern_002e-1">Searching for a pattern.</a>: <a href="#Introduction">Introduction</a></li>
  1745. <li><a href="#index-space-characters-202">space characters</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1746. <li><a href="#index-suppress-binary-data-82">suppress binary data</a>: <a href="#Invoking">Invoking</a></li>
  1747. <li><a href="#index-suppress-error-messages-29">suppress error messages</a>: <a href="#Invoking">Invoking</a></li>
  1748. <li><a href="#index-translation-of-message-language-142">translation of message language</a>: <a href="#Invoking">Invoking</a></li>
  1749. <li><a href="#index-upper_002dcase-letters-205">upper-case letters</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1750. <li><a href="#index-Usage-summary_002c-printing-55">Usage summary, printing</a>: <a href="#Invoking">Invoking</a></li>
  1751. <li><a href="#index-Usage_002c-examples-214">Usage, examples</a>: <a href="#Usage">Usage</a></li>
  1752. <li><a href="#index-Using-_0040command_007bgrep_007d_002c-Q_0026A-215">Using <samp><span class="command">grep</span></samp>, Q&A</a>: <a href="#Usage">Usage</a></li>
  1753. <li><a href="#index-Version_002c-printing-53">Version, printing</a>: <a href="#Invoking">Invoking</a></li>
  1754. <li><a href="#index-whitespace-characters-203">whitespace characters</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1755. <li><a href="#index-with-filename-prefix-69">with filename prefix</a>: <a href="#Invoking">Invoking</a></li>
  1756. <li><a href="#index-xdigit-class-207">xdigit class</a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1757. <li><a href="#index-zero_002dterminated-file-names-114">zero-terminated file names</a>: <a href="#Invoking">Invoking</a></li>
  1758. <li><a href="#index-zero_002dterminated-lines-117">zero-terminated lines</a>: <a href="#Invoking">Invoking</a></li>
  1759.    </ul><div class="node">
  1760. <p><hr>
  1761. <a name="Index"></a>
  1762. Previous: <a rel="previous" accesskey="p" href="#Concept-Index">Concept Index</a>,
  1763. Up: <a rel="up" accesskey="u" href="#Top">Top</a>
  1764.  
  1765. </div>
  1766.  
  1767. <h2 class="unnumbered">Index</h2>
  1768.  
  1769. <p>This is an alphabetical list of all <samp><span class="command">grep</span></samp> commands, command-line
  1770. options, and environment variables.
  1771.  
  1772.  
  1773.  
  1774. <ul class="index-fn" compact>
  1775. <li><a href="#index-g_t_002a-164"><code>*</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1776. <li><a href="#index-g_t_002b-167"><code>+</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1777. <li><a href="#index-g_t_002d_002dafter_002dcontext-38"><code>--after-context</code></a>: <a href="#Invoking">Invoking</a></li>
  1778. <li><a href="#index-g_t_002d_002dbasic_002dregexp-146"><code>--basic-regexp</code></a>: <a href="#Grep-Programs">Grep Programs</a></li>
  1779. <li><a href="#index-g_t_002d_002dbefore_002dcontext-42"><code>--before-context</code></a>: <a href="#Invoking">Invoking</a></li>
  1780. <li><a href="#index-g_t_002d_002dbinary-103"><code>--binary</code></a>: <a href="#Invoking">Invoking</a></li>
  1781. <li><a href="#index-g_t_002d_002dbinary_002dfiles-56"><code>--binary-files</code></a>: <a href="#Invoking">Invoking</a></li>
  1782. <li><a href="#index-g_t_002d_002dbyte_002doffset-59"><code>--byte-offset</code></a>: <a href="#Invoking">Invoking</a></li>
  1783. <li><a href="#index-g_t_002d_002dcolour-48"><code>--colour</code></a>: <a href="#Invoking">Invoking</a></li>
  1784. <li><a href="#index-g_t_002d_002dcontext-46"><code>--context</code></a>: <a href="#Invoking">Invoking</a></li>
  1785. <li><a href="#index-g_t_002d_002dcount-3"><code>--count</code></a>: <a href="#Invoking">Invoking</a></li>
  1786. <li><a href="#index-g_t_002d_002ddevices-62"><code>--devices</code></a>: <a href="#Invoking">Invoking</a></li>
  1787. <li><a href="#index-g_t_002d_002ddirectories-65"><code>--directories</code></a>: <a href="#Invoking">Invoking</a></li>
  1788. <li><a href="#index-g_t_002d_002dexclude-94"><code>--exclude</code></a>: <a href="#Invoking">Invoking</a></li>
  1789. <li><a href="#index-g_t_002d_002dextended_002dregexp-149"><code>--extended-regexp</code></a>: <a href="#Grep-Programs">Grep Programs</a></li>
  1790. <li><a href="#index-g_t_002d_002dfile-9"><code>--file</code></a>: <a href="#Invoking">Invoking</a></li>
  1791. <li><a href="#index-g_t_002d_002dfiles_002dwith_002dmatches-15"><code>--files-with-matches</code></a>: <a href="#Invoking">Invoking</a></li>
  1792. <li><a href="#index-g_t_002d_002dfiles_002dwithout_002dmatch-78"><code>--files-without-match</code></a>: <a href="#Invoking">Invoking</a></li>
  1793. <li><a href="#index-g_t_002d_002dfixed_002dstrings-152"><code>--fixed-strings</code></a>: <a href="#Grep-Programs">Grep Programs</a></li>
  1794. <li><a href="#index-g_t_002d_002dhelp-54"><code>--help</code></a>: <a href="#Invoking">Invoking</a></li>
  1795. <li><a href="#index-g_t_002d_002dignore_002dcase-12"><code>--ignore-case</code></a>: <a href="#Invoking">Invoking</a></li>
  1796. <li><a href="#index-g_t_002d_002dinclude-91"><code>--include</code></a>: <a href="#Invoking">Invoking</a></li>
  1797. <li><a href="#index-g_t_002d_002dinvert_002dmatch-31"><code>--invert-match</code></a>: <a href="#Invoking">Invoking</a></li>
  1798. <li><a href="#index-g_t_002d_002dlabel-75"><code>--label</code></a>: <a href="#Invoking">Invoking</a></li>
  1799. <li><a href="#index-g_t_002d_002dline_002dbuffered-73"><code>--line-buffered</code></a>: <a href="#Invoking">Invoking</a></li>
  1800. <li><a href="#index-g_t_002d_002dline_002dnumber-18"><code>--line-number</code></a>: <a href="#Invoking">Invoking</a></li>
  1801. <li><a href="#index-g_t_002d_002dline_002dregexp-35"><code>--line-regexp</code></a>: <a href="#Invoking">Invoking</a></li>
  1802. <li><a href="#index-g_t_002d_002dmax_002dcount-98"><code>--max-count</code></a>: <a href="#Invoking">Invoking</a></li>
  1803. <li><a href="#index-g_t_002d_002dmmap-110"><code>--mmap</code></a>: <a href="#Invoking">Invoking</a></li>
  1804. <li><a href="#index-g_t_002d_002dno_002dfilename-71"><code>--no-filename</code></a>: <a href="#Invoking">Invoking</a></li>
  1805. <li><a href="#index-g_t_002d_002dno_002dmessages-28"><code>--no-messages</code></a>: <a href="#Invoking">Invoking</a></li>
  1806. <li><a href="#index-g_t_002d_002dnull-113"><code>--null</code></a>: <a href="#Invoking">Invoking</a></li>
  1807. <li><a href="#index-g_t_002d_002dnull_002ddata-116"><code>--null-data</code></a>: <a href="#Invoking">Invoking</a></li>
  1808. <li><a href="#index-g_t_002d_002donly_002dmatching-21"><code>--only-matching</code></a>: <a href="#Invoking">Invoking</a></li>
  1809. <li><a href="#index-g_t_002d_002dperl_002dregexp-155"><code>--perl-regexp</code></a>: <a href="#Grep-Programs">Grep Programs</a></li>
  1810. <li><a href="#index-g_t_002d_002dquiet-24"><code>--quiet</code></a>: <a href="#Invoking">Invoking</a></li>
  1811. <li><a href="#index-g_t_002d_002drecursive-88"><code>--recursive</code></a>: <a href="#Invoking">Invoking</a></li>
  1812. <li><a href="#index-g_t_002d_002dregexp_003d_0040var_007bpattern_007d-6"><code>--regexp=</code><var>pattern</var></a>: <a href="#Invoking">Invoking</a></li>
  1813. <li><a href="#index-g_t_002d_002dsilent-25"><code>--silent</code></a>: <a href="#Invoking">Invoking</a></li>
  1814. <li><a href="#index-g_t_002d_002dtext-81"><code>--text</code></a>: <a href="#Invoking">Invoking</a></li>
  1815. <li><a href="#index-g_t_002d_002dunix_002dbyte_002doffsets-107"><code>--unix-byte-offsets</code></a>: <a href="#Invoking">Invoking</a></li>
  1816. <li><a href="#index-g_t_002d_002dversion-52"><code>--version</code></a>: <a href="#Invoking">Invoking</a></li>
  1817. <li><a href="#index-g_t_002d_002dWith_002dfilename-68"><code>--With-filename</code></a>: <a href="#Invoking">Invoking</a></li>
  1818. <li><a href="#index-g_t_002d_002dword_002dregexp-85"><code>--word-regexp</code></a>: <a href="#Invoking">Invoking</a></li>
  1819. <li><a href="#index-g_t_002da-80"><code>-a</code></a>: <a href="#Invoking">Invoking</a></li>
  1820. <li><a href="#index-g_t_002dA-37"><code>-A</code></a>: <a href="#Invoking">Invoking</a></li>
  1821. <li><a href="#index-g_t_002db-58"><code>-b</code></a>: <a href="#Invoking">Invoking</a></li>
  1822. <li><a href="#index-g_t_002dB-41"><code>-B</code></a>: <a href="#Invoking">Invoking</a></li>
  1823. <li><a href="#index-g_t_002dC-45"><code>-C</code></a>: <a href="#Invoking">Invoking</a></li>
  1824. <li><a href="#index-g_t_002dc-2"><code>-c</code></a>: <a href="#Invoking">Invoking</a></li>
  1825. <li><a href="#index-g_t_002dd-64"><code>-d</code></a>: <a href="#Invoking">Invoking</a></li>
  1826. <li><a href="#index-g_t_002dD-61"><code>-D</code></a>: <a href="#Invoking">Invoking</a></li>
  1827. <li><a href="#index-g_t_002dE-148"><code>-E</code></a>: <a href="#Grep-Programs">Grep Programs</a></li>
  1828. <li><a href="#index-g_t_002de-5"><code>-e</code></a>: <a href="#Invoking">Invoking</a></li>
  1829. <li><a href="#index-g_t_002dF-151"><code>-F</code></a>: <a href="#Grep-Programs">Grep Programs</a></li>
  1830. <li><a href="#index-g_t_002df-8"><code>-f</code></a>: <a href="#Invoking">Invoking</a></li>
  1831. <li><a href="#index-g_t_002dG-145"><code>-G</code></a>: <a href="#Grep-Programs">Grep Programs</a></li>
  1832. <li><a href="#index-g_t_002dh-70"><code>-h</code></a>: <a href="#Invoking">Invoking</a></li>
  1833. <li><a href="#index-g_t_002dH-67"><code>-H</code></a>: <a href="#Invoking">Invoking</a></li>
  1834. <li><a href="#index-g_t_002di-11"><code>-i</code></a>: <a href="#Invoking">Invoking</a></li>
  1835. <li><a href="#index-g_t_002dL-77"><code>-L</code></a>: <a href="#Invoking">Invoking</a></li>
  1836. <li><a href="#index-g_t_002dl-14"><code>-l</code></a>: <a href="#Invoking">Invoking</a></li>
  1837. <li><a href="#index-g_t_002dm-97"><code>-m</code></a>: <a href="#Invoking">Invoking</a></li>
  1838. <li><a href="#index-g_t_002dn-17"><code>-n</code></a>: <a href="#Invoking">Invoking</a></li>
  1839. <li><a href="#index-g_t_002dNUM-50"><code>-NUM</code></a>: <a href="#Invoking">Invoking</a></li>
  1840. <li><a href="#index-g_t_002do-20"><code>-o</code></a>: <a href="#Invoking">Invoking</a></li>
  1841. <li><a href="#index-g_t_002dP-154"><code>-P</code></a>: <a href="#Grep-Programs">Grep Programs</a></li>
  1842. <li><a href="#index-g_t_002dq-23"><code>-q</code></a>: <a href="#Invoking">Invoking</a></li>
  1843. <li><a href="#index-g_t_002dr-87"><code>-r</code></a>: <a href="#Invoking">Invoking</a></li>
  1844. <li><a href="#index-g_t_002ds-27"><code>-s</code></a>: <a href="#Invoking">Invoking</a></li>
  1845. <li><a href="#index-g_t_002du-106"><code>-u</code></a>: <a href="#Invoking">Invoking</a></li>
  1846. <li><a href="#index-g_t_002dU-102"><code>-U</code></a>: <a href="#Invoking">Invoking</a></li>
  1847. <li><a href="#index-g_t_002dV-51"><code>-V</code></a>: <a href="#Invoking">Invoking</a></li>
  1848. <li><a href="#index-g_t_002dv-30"><code>-v</code></a>: <a href="#Invoking">Invoking</a></li>
  1849. <li><a href="#index-g_t_002dw-84"><code>-w</code></a>: <a href="#Invoking">Invoking</a></li>
  1850. <li><a href="#index-g_t_002dx-34"><code>-x</code></a>: <a href="#Invoking">Invoking</a></li>
  1851. <li><a href="#index-g_t_002dy-100"><code>-y</code></a>: <a href="#Invoking">Invoking</a></li>
  1852. <li><a href="#index-g_t_002dz-115"><code>-z</code></a>: <a href="#Invoking">Invoking</a></li>
  1853. <li><a href="#index-g_t_002dZ-112"><code>-Z</code></a>: <a href="#Invoking">Invoking</a></li>
  1854. <li><a href="#index-g_t_002e-158"><code>.</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1855. <li><a href="#index-g_t_003f-161"><code>?</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1856. <li><a href="#index-g_t_005f_0040var_007bN_007d_005fGNU_005fnonoption_005fargv_005fflags_005f-144"><code>_</code><var>N</var><code>_GNU_nonoption_argv_flags_</code></a>: <a href="#Invoking">Invoking</a></li>
  1857. <li><a href="#index-alnum-182"><code>alnum</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1858. <li><a href="#index-alpha-184"><code>alpha</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1859. <li><a href="#index-blank-186"><code>blank</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1860. <li><a href="#index-cntrl-188"><code>cntrl</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1861. <li><a href="#index-digit-190"><code>digit</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1862. <li><a href="#index-graph-193"><code>graph</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1863. <li><a href="#index-GREP_005fCOLOR-121"><code>GREP_COLOR</code></a>: <a href="#Invoking">Invoking</a></li>
  1864. <li><a href="#index-GREP_005fOPTIONS-119"><code>GREP_OPTIONS</code></a>: <a href="#Invoking">Invoking</a></li>
  1865. <li><a href="#index-LANG-125"><code>LANG</code></a>: <a href="#Invoking">Invoking</a></li>
  1866. <li><a href="#index-LC_005fALL-123"><code>LC_ALL</code></a>: <a href="#Invoking">Invoking</a></li>
  1867. <li><a href="#index-LC_005fCOLLATE-124"><code>LC_COLLATE</code></a>: <a href="#Invoking">Invoking</a></li>
  1868. <li><a href="#index-LC_005fCTYPE-130"><code>LC_CTYPE</code></a>: <a href="#Invoking">Invoking</a></li>
  1869. <li><a href="#index-LC_005fMESSAGES-136"><code>LC_MESSAGES</code></a>: <a href="#Invoking">Invoking</a></li>
  1870. <li><a href="#index-lower-195"><code>lower</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1871. <li><a href="#index-POSIXLY_005fCORRECT-143"><code>POSIXLY_CORRECT</code></a>: <a href="#Invoking">Invoking</a></li>
  1872. <li><a href="#index-print-197"><code>print</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1873. <li><a href="#index-punct-199"><code>punct</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1874. <li><a href="#index-space-201"><code>space</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1875. <li><a href="#index-upper-204"><code>upper</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1876. <li><a href="#index-xdigit-206"><code>xdigit</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1877. <li><a href="#index-g_t_0040_007bn_002cm_0040_007d-175"><code>{n,m}</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1878. <li><a href="#index-g_t_0040_007bn_002c_0040_007d-172"><code>{n,}</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1879. <li><a href="#index-g_t_0040_007bn_0040_007d-169"><code>{n}</code></a>: <a href="#Regular-Expressions">Regular Expressions</a></li>
  1880.    </ul>
  1881. <div class="contents">
  1882. <h2>Table of Contents</h2>
  1883. <ul>
  1884. <li><a name="toc_Top" href="#Top">Grep</a>
  1885. <li><a name="toc_Introduction" href="#Introduction">1 Introduction</a>
  1886. <li><a name="toc_Invoking" href="#Invoking">2 Invoking <samp><span class="command">grep</span></samp></a>
  1887. <ul>
  1888. <li><a href="#Invoking">2.1 <span class="sc">gnu</span> Extensions</a>
  1889. <li><a href="#Invoking">2.2 Environment Variables</a>
  1890. </li></ul>
  1891. <li><a name="toc_Diagnostics" href="#Diagnostics">3 Diagnostics</a>
  1892. <li><a name="toc_Grep-Programs" href="#Grep-Programs">4 <samp><span class="command">grep</span></samp> programs</a>
  1893. <li><a name="toc_Regular-Expressions" href="#Regular-Expressions">5 Regular Expressions</a>
  1894. <ul>
  1895. <li><a href="#Regular-Expressions">5.1 Character Class</a>
  1896. <li><a href="#Regular-Expressions">5.2 Backslash Character</a>
  1897. <li><a href="#Regular-Expressions">5.3 Anchoring</a>
  1898. <li><a href="#Regular-Expressions">5.4 Back-reference</a>
  1899. <li><a href="#Regular-Expressions">5.5 Basic vs Extended</a>
  1900. </li></ul>
  1901. <li><a name="toc_Usage" href="#Usage">6 Usage</a>
  1902. <li><a name="toc_Reporting-Bugs" href="#Reporting-Bugs">7 Reporting bugs</a>
  1903. <li><a name="toc_Copying" href="#Copying">8 Copying</a>
  1904. <ul>
  1905. <li><a href="#GNU-General-Public-License">8.1 GNU General Public License</a>
  1906. <li><a href="#GNU-General-Public-License">Preamble</a>
  1907. <li><a href="#GNU-General-Public-License">How to Apply These Terms to Your New Programs</a>
  1908. <li><a href="#GNU-Free-Documentation-License">8.2 GNU Free Documentation License</a>
  1909. <li><a href="#GNU-Free-Documentation-License">ADDENDUM: How to use this License for your documents</a>
  1910. </li></ul>
  1911. <li><a name="toc_Concept-Index" href="#Concept-Index">Concept Index</a>
  1912. <li><a name="toc_Index" href="#Index">Index</a>
  1913. </li></ul>
  1914. </div>
  1915.  
  1916. </body></html>
  1917.  
  1918.