home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / eel / grep04.zip / GREP.DOC < prev    next >
Text File  |  1989-09-21  |  9KB  |  265 lines

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