home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / man / cat1 / grep.0 < prev    next >
Text File  |  1993-12-07  |  11KB  |  265 lines

  1.  
  2.  
  3.  
  4. GREP(1)                                                   GREP(1)
  5.  
  6.  
  7. NNAAMMEE
  8.        grep, egrep, fgrep - print lines matching a pattern
  9.  
  10. SSYYNNOOPPOOSSIISS
  11.        ggrreepp [ --[[AABB] ]_n_u_m ] [ --[CCEEFFGGVVBBcchhiillnnssvvwwxx] ] [ --ee ] _p_a_t_t_e_r_n
  12.        | --ff_f_i_l_e ] [ _f_i_l_e_s_._._.  ]
  13.  
  14. DDEESSCCRRIIPPTTIIOONN
  15.        GGrreepp searches the named input _f_i_l_e_s (or standard input  if
  16.        no files are named, or the file name -- is given) for lines
  17.        containing a match to the given _p_a_t_t_e_r_n.  By default, ggrreepp
  18.        prints the matching lines.
  19.  
  20.        There  are three major variants of ggrreepp, controlled by the
  21.        following options.
  22.        --GG     Interpret _p_a_t_t_e_r_n as  a  basic  regular  expression
  23.               (see below).  This is the default.
  24.        --EE     Interpret _p_a_t_t_e_r_n as an extended regular expression
  25.               (see below).
  26.        --FF     Interpret _p_a_t_t_e_r_n as a list of fixed strings, sepa-
  27.               rated by newlines, any of which is to be matched.
  28.        In  addition,  two  variant  programs  eeggrreepp and ffggrreepp are
  29.        available.  EEggrreepp  is  similiar  (but  not  identical)  to
  30.        ggrreepp --EE, and is compatible with the historical Unix eeggrreepp.
  31.        FFggrreepp is the same as ggrreepp --FF.
  32.  
  33.        All variants of ggrreepp understand the following options:
  34.        --_n_u_m   Matches will be printed with _n_u_m lines  of  leading
  35.               and  trailing  context.   However,  ggrreepp will never
  36.               print any given line more than once.
  37.        --AA _n_u_m Print _n_u_m lines of trailing context after  matching
  38.               lines.
  39.        --BB _n_u_m Print  _n_u_m lines of leading context before matching
  40.               lines.
  41.        --CC     Equivalent to --22.
  42.        --VV     Print the version number of ggrreepp to standard error.
  43.               This  version  number should be included in all bug
  44.               reports (see below).
  45.        --bb     Print the byte offset within the input file  before
  46.               each line of output.
  47.        --cc     Suppress  normal  output;  instead print a count of
  48.               matching lines for each input file.   With  the  --vv
  49.               option (see below), count non-matching lines.
  50.        --ee _p_a_t_t_e_r_n
  51.               Use  _p_a_t_t_e_r_n as the pattern; useful to protect pat-
  52.               terns beginning with --.
  53.        --ff _f_i_l_e
  54.               Obtain the pattern from _f_i_l_e.
  55.        --hh     Suppress the prefixing of filenames on output  when
  56.               multiple files are searched.
  57.        --ii     Ignore  case  distinctions  in both the _p_a_t_t_e_r_n and
  58.               the input files.
  59.        --LL     Suppress normal output; instead print the  name  of
  60.               each input file from which no output would normally
  61.  
  62.  
  63.  
  64. GNU Project             1992 September 10                       1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. GREP(1)                                                   GREP(1)
  71.  
  72.  
  73.               have been printed.
  74.        --ll     Suppress normal output; instead print the  name  of
  75.               each  input  file  from which output would normally
  76.               have been printed.
  77.        --nn     Prefix each line of output  with  the  line  number
  78.               within its input file.
  79.        --qq     Quiet; suppress normal output.
  80.        --ss     Suppress   error   messages  about  nonexistent  or
  81.               unreadable files.
  82.        --vv     Invert  the  sense  of  matching,  to  select  non-
  83.               matching lines.
  84.        --ww     Select  only  those  lines  containing matches that
  85.               form whole words.  The test is  that  the  matching
  86.               substring  must  either  be at the beginning of the
  87.               line, or preceded by a non-word constituent charac-
  88.               ter.   Similarly,  it  must be either at the end of
  89.               the line or  followed  by  a  non-word  constituent
  90.               character.   Word-constituent  characters  are let-
  91.               ters, digits, and the underscore.
  92.        --xx     Select only those matches that  exactly  match  the
  93.               whole line.
  94.  
  95. RREEGGUULLAARR EEXXPPRREESSSSIIOONNSS
  96.        A  regular expression is a pattern that describes a set of
  97.        strings.  Regular expressions are constructed  analagously
  98.        to  arithmetic  expressions, by using various operators to
  99.        combine smaller expressions.
  100.  
  101.        GGrreepp understands two different versions of regular expres-
  102.        sion  syntax:  ``basic''  and  ``extended.''  In GNU ggrreepp,
  103.        there is no difference in  available  functionality  using
  104.        either  syntax.   In  other implementations, basic regular
  105.        expressions are less powerful.  The following  description
  106.        applies  to  extended regular expressions; differences for
  107.        basic regular expressions are summarized afterwards.
  108.  
  109.        The fundamental building blocks are  the  regular  expres-
  110.        sions  that  match  a  single character.  Most characters,
  111.        including all letters and digits, are regular  expressions
  112.        that  match  themselves.   Any  metacharacter with special
  113.        meaning may be quoted by preceding it with a backslash.
  114.  
  115.        A list of characters enclosed by [[ and ]] matches any  sin-
  116.        gle  character in that list; if the first character of the
  117.        list is the caret ^^ then it matches any character  _n_o_t  in
  118.        the   list.    For   example,   the   regular   expression
  119.        [[00112233445566778899]] matches any single digit.  A range  of  ASCII
  120.        characters  may  be specified by giving the first and last
  121.        characters, separated by a hyphen.  Finally, certain named
  122.        classes  of  characters  are  predefined.  Their names are
  123.        self  explanatory,  and  they  are  [[::aallnnuumm::]],  [[::aallpphhaa::]],
  124.        [[::ccnnttrrll::]],  [[::ddiiggiitt::]],  [[::ggrraapphh::]],  [[::lloowweerr::]],  [[::pprriinntt::]],
  125.        [[::ppuunncctt::]],  [[::ssppaaccee::]],  [[::uuppppeerr::]],  and  [[::xxddiiggiitt::]]..   For
  126.        example,  [[[[::aallnnuumm::]]]] means [[00--99AA--ZZaa--zz]], except the latter
  127.  
  128.  
  129.  
  130. GNU Project             1992 September 10                       2
  131.  
  132.  
  133.  
  134.  
  135.  
  136. GREP(1)                                                   GREP(1)
  137.  
  138.  
  139.        form is  dependent  upon  the  ASCII  character  encoding,
  140.        whereas  the  former is portable.  (Note that the brackets
  141.        in these class names are part of the symbolic  names,  and
  142.        must  be  included  in addition to the brackets delimiting
  143.        the bracket list.)  Most metacharacters lose their special
  144.        meaning  inside  lists.   To  include a literal ]] place it
  145.        first in the list.  Similarly,  to  include  a  literal  ^^
  146.        place  it  anywhere but first.  Finally, to include a lit-
  147.        eral -- place it last.
  148.  
  149.        The period ..  matches any single character.  The symbol \\ww
  150.        is  a  synonym  for  [[[[::aallnnuumm::]]]]  and  \\WW is a synonym for
  151.        [[^^[[::aallnnuumm]]]].
  152.  
  153.        The caret ^^ and the dollar sign $$ are metacharacters  that
  154.        respectively  match  the empty string at the beginning and
  155.        end of a line.  The symbols \\<< and \\>>  respectively  match
  156.        the  empty string at the beginning and end of a word.  The
  157.        symbol \\bb matches the empty string at the edge of a  word,
  158.        and  \\BB  matches the empty string provided it's _n_o_t at the
  159.        edge of a word.
  160.  
  161.        A regular expression matching a single  character  may  be
  162.        followed by one of several repetition operators:
  163.        ??      The  preceding item is optional and matched at most
  164.               once.
  165.        **      The preceding item will be  matched  zero  o