home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / ntcode / gnugrep / grep.man < prev    next >
Encoding:
Text File  |  1995-05-19  |  8.7 KB  |  197 lines

  1.  
  2.    NNAAMMEE
  3.       grep, egrep - print lines matching a regular expression
  4.  
  5.    SSYYNNOOPPSSIISS
  6.       ggrreepp [-CVbchilnsvwx] [-_n_u_m] [-AB _n_u_m] [[-e] _e_x_p_r | -f _f_i_l_e]
  7.                                                             [_f_i_l_e_s ...]
  8.  
  9.    IIMMPPOORRTTAANNTT  NNOOTTEE
  10.       The ggrreepp in question is the GNU ee??ggrreepp, based on a fast lazy-state
  11.       deterministic matcher (about twice as fast as stock Unix egrep)
  12.       hybridized with a Boyer-Moore-Gosper search for a fixed string that
  13.       eliminates impossible text from being considered by the full regexp
  14.       matcher without necessarily having to look at every character.  The
  15.       result is typically many times faster than Unix grep or egrep.
  16.       (Regular expressions containing backreferencing may run more
  17.       slowly, however.)
  18.  
  19.    DDEESSCCRRIIPPTTIIOONN
  20.       ggrreepp searches the files listed in the arguments (or standard input
  21.       if no files are given) for all lines that contain a match for the
  22.       given _e_x_p_r.  If any lines match, they are printed.
  23.  
  24.       Also, if any matches were found, ggrreepp will exit with a status of 0,
  25.       but if no matches were found it will exit with a status of 1.  This
  26.       is useful for building shell scripts that use ggrreepp as a condition
  27.       for, for example, the _I_F_ _E_R_R_O_R_L_E_V_E_L_ _._._. statement.
  28.  
  29.       When invoked as eeggrreepp the syntax of the _e_x_p_r is slightly different;
  30.       see below.
  31.  
  32.    RREEGGUULLAARR  EEXXPPRREESSSSIIOONNSS
  33.       (grep)   (egrep)  (explanation)
  34.  
  35.       _c         _c       a single (non-meta) character matches itself.
  36.  
  37.       .        .        matches any single character except newline.
  38.  
  39.       ?        ?        postfix operator;  preceeding item is optional.
  40.  
  41.       *        *        postfix operator;  preceeding item 0 or more
  42.                         times.
  43.  
  44.       +        +        postfix operator;  preceeding item 1 or more
  45.                         times.
  46.  
  47.       |        |        infix operator;  matches either argument.
  48.  
  49.       ^        ^        matches the empty string at the beginning of a
  50.                         line.
  51.  
  52.       $        $        matches the empty string at the end of a line.
  53.  
  54.       <        <        matches the empty string at the beginning of a
  55.                         word.
  56.  
  57.       >        >        matches the empty string at the end of a word.
  58.  
  59.       [_c_h_a_r_s]  [_c_h_a_r_s]  match any character in the given class;  if the
  60.                         first character after [ is ^, match any character
  61.                         not in the given class;  a range of characters
  62.                         may be specified by _f_i_r_s_t-_l_a_s_t;  for example, W
  63.                         (below) is equivalent to the class [^A-Za-z0-9]
  64.  
  65.       ( )      ( )      parentheses are used to override operator
  66.                         precedence.
  67.  
  68.       \_d_i_g_i_t   \_d_i_g_i_t   \_n matches a repeat of the text matched earlier
  69.                         in the regexp by the subexpression inside the _nth
  70.                         opening parenthesis.
  71.  
  72.       \        \        any special character may be preceded by a
  73.                         backslash to match it literally.
  74.  
  75.       (the following are for compatibility with GNU Emacs)
  76.  
  77.       \b       \b       matches the empty string at the edge of a word.
  78.  
  79.       \B       \B       matches the empty string if not at the edge of a
  80.                         word.
  81.  
  82.       \w       \w       matches word-constituent characters (letters &
  83.                         digits).
  84.  
  85.       \W       \W       matches characters that are not word-constituent.
  86.  
  87.       Operator precedence is (highest to lowest) ?, *, and +,
  88.       concatenation, and finally |.  All other constructs are
  89.       syntactically identical to normal characters.  For the truly
  90.       interested, the file dfa.c describes (and implements) the exact
  91.       grammar understood by the parser.
  92.  
  93.    OOPPTTIIOONNSS
  94.       --AA _n_u_m      print _n_u_m lines of context after every matching line
  95.  
  96.       --BB _n_u_m      print _n_u_m lines of context before every matching line
  97.  
  98.       --CC          print 2 lines of context on each side of every match
  99.  
  100.       -_n_u_m        print _n_u_m lines of context on each side of every match
  101.  
  102.       --VV          print the version number on the diagnostic output
  103.  
  104.       --bb          print every match preceded by its byte offset
  105.  
  106.       --cc          print a total count of matching lines only
  107.  
  108.       --ee _e_x_p_r     search for _e_x_p_r;  useful if _e_x_p_r begins with -
  109.  
  110.       --ff _f_i_l_e     search for the expression contained in _f_i_l_e
  111.  
  112.       --hh          don't display filenames on matches
  113.  
  114.       --ii          ignore case difference when comparing strings
  115.  
  116.       --ll          list files containing matches only
  117.  
  118.       --nn          print each match preceded by its line number
  119.  
  120.       --ss          run silently producing no output except error messages
  121.  
  122.       --vv          print only lines that contain no matches for the <expr>
  123.  
  124.       --ww          print only lines where the match is a complete word
  125.  
  126.       --xx          print only lines where the match is a whole line
  127.  
  128.    IINNCCOOMMPPAATTIIBBIILLIITTIIEESS
  129.       The following incompatibilities with UNIX _g_r_e_p exist:
  130.  
  131.       The context-dependent meaning of * is not quite the same (grep
  132.       only).
  133.  
  134.       -b prints a byte offset instead of a block offset.
  135.  
  136.       The {_m,_n} construct of System V grep is not implemented.
  137.  
  138.    BBUUGGSS
  139.       GNU _e_?_g_r_e_p has been thoroughly debugged and tested by several
  140.       people over a period of several months;  we think it's a reliable
  141.       beast or we wouldn't distribute it.  If by some fluke of the
  142.       universe you discover a bug, send a detailed description (including
  143.       options, regular expressions, and a copy of an input file that can
  144.       reproduce it) to me, mike@wheaties.ai.mit.edu.
  145.  
  146.       There is also a newsgroup, gnu.utils.bug, for reporting FSF utility
  147.       programs' bugs and fixes;  but before reporting something as a bug,
  148.       please try to be sure that it really is a bug, not a
  149.       misunderstanding or a deliberate feature.  Also, include the
  150.       version number of the utility program you are running in _e_v_e_r_y bug
  151.       report that you send in.  Please do not send anything but bug
  152.       reports to this newsgroup.
  153.  
  154.    AAVVAAIILLAABBIILLIITTYY
  155.       GNU ggrreepp is free;  anyone may redistribute copies of ggrreepp to anyone
  156.       under the terms stated in the GNU General Public License, a copy of
  157.       which may be found in each copy of _G_N_U_ _E_m_a_c_s.  See also the comment
  158.       at the beginning of the source code file grep.c.
  159.  
  160.       Copies of GNU ggrreepp may sometimes be received packaged with
  161.       distributions of Unix systems, but it is never included in the
  162.       scope of any license covering those systems.  Such inclusion
  163.       violates the terms on which distribution is permitted.  In fact,
  164.       the primary purpose of the General Public License is to prohibit
  165.       anyone from attaching any other restrictions to redistribution of
  166.       any of the Free Software Foundation programs.
  167.  
  168.    AAUUTTHHOORRSS
  169.       Mike Haertel wrote the deterministic regexp code and the bulk of
  170.       the program.
  171.  
  172.       James A. Woods is responsible for the hybridized search strategy of
  173.       using Boyer-Moore-Gosper fixed-string search as a filter before
  174.       calling the general regexp matcher.
  175.  
  176.       Arthur David Olson contributed code that finds fixed strings for
  177.       the aforementioned BMG search for a large class of regexps.
  178.  
  179.       Richard Stallman wrote the backtracking regexp matcher that is used
  180.       for \_d_i_g_i_t backreferences, as well as the getopt that is provided
  181.       for 4.2BSD sites.  The backtracking matcher was originally written
  182.       for GNU Emacs.
  183.  
  184.       D. A. Gwyn wrote the C alloca emulation that is provided so System
  185.       V machines can run this program.  (Alloca is used only by RMS'
  186.       backtracking matcher, and then only rarely, so there is no loss if
  187.       your machine doesn't have a "real" alloca.)
  188.  
  189.       Frank Whaley has ported the software to "toy" operating systems
  190.       such as MS-DOS and OS/2.
  191.  
  192.       Scott Anderson and Henry Spencer designed the regression tests used
  193.       in the "regress" script.
  194.  
  195.       Paul Placeway wrote the original version of this manual page.
  196.  
  197.