home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff295.lzh / GnuGrep / grep.man < prev    next >
Text File  |  1989-12-27  |  9KB  |  265 lines

  1.  
  2.  
  3.  
  4. GREP(1)                   USER COMMANDS                   GREP(1)
  5.  
  6.  
  7.  
  8. NAME
  9.      grep, egrep - print lines matching a regular expression
  10.  
  11. SYNOPSIS
  12.      grep [ -CVbchilnsvwx ] [ -_n_u_m ] [ -AB _n_u_m ] [ [ -e ] _e_x_p_r  |
  13.      -f _f_i_l_e ] [ _f_i_l_e_s ... ]
  14.  
  15. DESCRIPTION
  16.      _G_r_e_p 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 _e_x_p_r.  If  any  lines  match,  they  are
  19.      printed.
  20.  
  21.      Also, if any matches were  found,  _g_r_e_p  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 _g_r_e_p as a condition for, for example, the _i_f state-
  25.      ment.
  26.  
  27.      When invoked as _e_g_r_e_p the syntax of  the  _e_x_p_r  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. GNU Project       Last change: 1988 December 13                 1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. GREP(1)                   USER COMMANDS                   GREP(1)
  71.  
  72.  
  73.  
  74.           \>        \>        matches the empty string at the end
  75.                               of a word.
  76.  
  77.           [_c_h_a_r_s]   [_c_h_a_r_s]   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 charac-
  81.                               ters   may    be    specified    by
  82.                               _f_i_r_s_t-_l_a_s_t; 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.           \_d_i_g_i_t    \_d_i_g_i_t    \_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  pre-
  95.                               ceded  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 +, con-
  113.      catenation, and finally |.  All other constructs are syntac-
  114.      tically 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 _n_u_m
  120.           print <num> lines of context after every matching line
  121.  
  122.      -B _n_u_m
  123.           print _n_u_m 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. GNU Project       Last change: 1988 December 13                 2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. GREP(1)                   USER COMMANDS                   GREP(1)
  137.  
  138.  
  139.  
  140.      -_n_u_m print _n_u_m 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 _e_x_p_r
  149.           search for _e_x_p_r; useful if _e_x_p_r begins with -
  150.  
  151.      -f _f_i_l_e
  152.           search for the expression contained in _f_i_l_e
  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), _G_N_U _E_m_a_c_s _M_a_n_u_a_l
  172.  
  173. INCOMPATIBILITIES
  174.      The following incompatibilities with UNIX _g_r_e_p 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  imple-
  182.           mented.
  183.  
  184. BUGS
  185.      GNU _e?_g_r_e_p  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  expres-
  190.      sions, and a copy of an input file that can reproduce it) to
  191.      me, mike@wheaties.ai.mit.edu.
  192.  
  193.  
  194.  
  195. GNU Project       Last change: 1988 December 13                 3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. GREP(1)                   USER COMMANDS                   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 some-
  208.      thing as a bug, please try to be sure that it  really  is  a
  209.      bug,  not a misunderstanding or a deliberate feature.  Also,
  210.      include the version number of the utility  program  you  are
  211.      running in _e_v_e_r_y bug report that you send in.  Please do not
  212.      send anything but bug reports to this newsgroup.
  213.  
  214. AVAILABILITY
  215.      GNU _g_r_e_p is free; anyone may redistribute copies of _g_r_e_p  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  _G_N_U
  218.      _E_m_a_c_s.   See also the comment at the beginning of the source
  219.      code file grep.c.
  220.  
  221.      Copies of GNU _g_r_e_p 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 per-
  225.      mitted.  In fact, the primary purpose of the General  Public
  226.      License  is to prohibit anyone from attaching any other res-
  227.      trictions to redistribution of  any  of  the  Free  Software
  228.      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 \fIdigit 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. GNU Project       Last change: 1988 December 13                 4
  262.  
  263.  
  264.  
  265.