


_O_n_l_i_n_e _M_a_n_u_a_l             User Commands                   grep(1)



NNNNAAAAMMMMEEEE
     grep, egrep, fgrep - search a file for a pattern

SSSSYYYYNNNNTTTTAAAAXXXX
     ggggrrrreeeepppp [ option ] ...  expression [ file ] ...

     eeeeggggrrrreeeepppp [ option ] ...  [ expression ] [ file ] ...

     ffffggggrrrreeeepppp [ option ] ...  [ strings ] [ file ]

DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
     Commands of the _g_r_e_p family search the input _f_i_l_e_s (standard
     input default) for lines matching a pattern.  Normally, each
     line found is copied to the standard output.  _g_r_e_p patterns
     are limited regular expressions in the style of _e_x(1); it
     uses a compact nondeterministic algorithm.  _e_g_r_e_p patterns
     are full regular expressions; it uses a fast deterministic
     algorithm that sometimes needs exponential space.  _f_g_r_e_p
     patterns are fixed strings; it is fast and compact.  The
     following options are recognized.

     ----vvvv   All lines but those matching are printed.

     ----xxxx   (Exact) only lines matched in their entirety are
          printed (_f_g_r_e_p only).

     ----cccc   Only a count of matching lines is printed.

     ----llll   The names of files with matching lines are listed
          (once) separated by newlines.

     ----nnnn   Each line is preceded by its relative line number in
          the file.

     ----bbbb   Each line is preceded by the block number on which it
          was found.  This is sometimes useful in locating disk
          block numbers by context.

     ----hhhh   Suppresses printing of file names when there is more
          than one input file.

     ----iiii   The case of letters is ignored in making comparisons -
          that is, upper and lower case are considered identical.
          This applies to _g_r_e_p and _f_g_r_e_p only.

     ----ssss   Silent mode.  Nothing is printed (except error mes-
          sages).  This is useful for checking the error status.

     ----wwww   The expression is searched for as a word (as if sur-
          rounded by `\<' and `\>', see _e_x(1).) (_g_r_e_p only)

     ----eeee _e_x_p_r_e_s_s_i_o_n
          Same as a simple _e_x_p_r_e_s_s_i_o_n argument, but useful when
          the _e_x_p_r_e_s_s_i_o_n begins with a -.

     ----ffff _f_i_l_e
          The regular expression (_e_g_r_e_p) or string list (_f_g_r_e_p)
          is taken from the _f_i_l_e.







     In all cases the file name is shown if there is more than
     one input file (except when the ----hhhh option is used).  Care
     should be taken when using the characters $ * [ ^ | ( ) and
     \ in the _e_x_p_r_e_s_s_i_o_n as they are also meaningful to the
     Shell.  It is safest to enclose the entire _e_x_p_r_e_s_s_i_o_n argu-
     ment in single quotes ' '.

     _f_g_r_e_p searches for lines that contain one of the (newline-
     separated) _s_t_r_i_n_g_s.

     _e_g_r_e_p accepts extended regular expressions.  In the follow-
     ing description `character' excludes newline:

          A \ followed by a single character other than newline
          matches that character.

          The character ^ matches the beginning of a line.

          The character $ matches the end of a line.

          A .... (period) matches any character.

          A single character not otherwise endowed with special
          meaning matches that character.

          A string enclosed in brackets [] matches any single
          character in the string (or not in the string if pre-
          ceded by ^).  Ranges of ASCII character codes may be
          abbreviated as in `a-z0-9'.  A ] may occur only as the
          first character of the string.  A literal - must be
          placed where it can't be mistaken as a range indicator.

          A regular expression followed by an * (asterisk)
          matches a sequence of 0 or more matches of the regular
          expression.  A regular expression followed by a +
          (plus) matches a sequence of 1 or more matches of the
          regular expression.  A regular expression followed by a
          ? (question mark) matches a sequence of 0 or 1 matches
          of the regular expression.

          Two regular expressions concatenated match a match of
          the first followed by a match of the second.

          Two regular expressions separated by | or newline match
          either a match for the first or a match for the second.

          A regular expression enclosed in parentheses matches a
          match for the regular expression.

     The order of precedence of operators at the same parenthesis
     level is [] then *+? then concatenation then | and newline.

     Ideally there should be only one _g_r_e_p, but we don't know a
     single algorithm that spans a wide enough range of space-
     time tradeoffs.

SSSSEEEEEEEE AAAALLLLSSSSOOOO
     User Commands (1):  ex, sed, sh








DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
     Exit status is 0 if any matches are found, 1 if none, 2 for
     syntax errors or inaccessible files.

MMMMEEEESSSSSSSSAAAAGGGGEEEESSSS
     grep: unknown flag
               You specified an option which _g_r_e_p doesn't recog-
               nize.  Check the manual page above for the
               options.

     grep: argument too long
               The regular expression is currently limited to 251
               characters.  You will have to simplify the expres-
               sion.

     grep: RE error
               You have made a mistake in specifying the regular
               expression.  For instance, a pattern such as the
               following indicates a badly formed regular expres-
               sion.

          % ggggrrrreeeepppp  ''''[[[[^^^^]]]]''''  ssssoooommmmeeeeffffiiiilllleeee

     grep: can't open _f_i_l_e_n_a_m_e
               _g_r_e_p cannot access the file specified by _f_i_l_e_n_a_m_e.
               Check that the filename is spelled correctly, or
               that you have read permission for that file.

     grep RE botch
               This means that _g_r_e_p is confused.  This implies an
               internal error in the program.

LLLLIIIIMMMMIIIITTTTAAAATTTTIIIIOOOONNNNSSSS
     Lines are limited to 256 characters; longer lines are trun-
     cated.

January 1990                                  TX User's Reference























