Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ grep(1) — A/UX 0.7

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

csh(1)

ksh(1)

ed(1)

sed(1)

sh(1)



     grep(1)                                                   grep(1)



     NAME
          grep, egrep, fgrep - search a file for a pattern

     SYNOPSIS
          grep [-b] [-c] [-i] [-n] [-s] [-v] expression [files]

          egrep [-b] [-c] [-e expression] [-f file] [-i] [-n] [-v]
          [expression] [files]

          fgrep [-b] [-c] [-e expression] [-f file] [-i] [-n] [-v]
          [-x] [strings] [files]

     DESCRIPTION
          Commands of the grep family search the input files (standard
          input default) for lines matching a pattern.  Normally, each
          line found is copied to the standard output.  grep patterns
          are limited regular expressions in the style of ed(1); it
          uses a compact non-deterministic algorithm.  egrep patterns
          are full regular expressions; it uses a fast deterministic
          algorithm that sometimes needs exponential space.  fgrep
          patterns are fixed strings; it is fast and compact.  The
          following flag options are recognized:

          -v           All lines but those matching are printed.

          -x           (Exact) only lines matched in their entirety
                       are printed (fgrep only).

          -c           Only a count of matching lines is printed.

          -i           Ignore upper/lowercase distinction during
                       comparisons.

          -l           Only the names of files with matching lines are
                       listed (once), separated by newlines.

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

          -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.

          -s           The error messages produced for nonexistent or
                       unreadable files are suppressed (grep only).

          -e expression
                       Same as a simple expression argument, but
                       useful when the expression begins with a -
                       (does not work with grep).

          -f file      The regular expression (egrep) or strings list



     Page 1                                        (last mod. 1/16/87)





     grep(1)                                                   grep(1)



                       (fgrep) is taken from the file.

          In all cases, the file name is output if there is more than
          one input file.  Care should be taken when using the
          characters $, *, [, ^, |, (, ), and \ in expression, because
          they are also meaningful to the shell.  It is safest to
          enclose the entire expression argument in single quotes
          '...'.

          Fgrep searches for lines that contain one of the strings
          separated by newlines.

          Egrep accepts regular expressions as in ed(1), except for \(
          and \), with the addition of:

          1. A regular expression followed by + matches one or more
             occurrences of the regular expression.
          2. A regular expression followed by ? matches 0 or 1
             occurrences of the regular expression.
          3. Two regular expressions separated by | or by a newline
             match strings that are matched by either.
          4. A regular expression may be enclosed in parentheses ()
             for grouping.

          The order of precedence of operators is [], then *?+, then
          concatenation, then | and newline.

     EXAMPLE
               grep -v -c 'regular' grep.1

          reports a count of the number of lines that do not contain
          the word regular in the file grep.1.

     FILES
          /bin/grep
          /bin/egrep
          /bin/fgrep

     SEE ALSO
          csh(1), ksh(1), ed(1), sed(1), sh(1).

     DIAGNOSTICS
          Exit status is 0 if any matches are found, 1 if none, 2 for
          syntax errors or inaccessible files (even if matches were
          found).

     BUGS
          Ideally there should be only one grep, but we do not know a
          single algorithm that spans a wide enough range of space-
          time tradeoffs.
          Lines are limited to BUFSIZ characters; longer lines are
          truncated.  (BUFSIZ is defined in /usr/include/stdio.h.)



     Page 2                                        (last mod. 1/16/87)





     grep(1)                                                   grep(1)



          Egrep does not recognize ranges, such as [a-z], in character
          classes.
          If there is a line with embedded nulls, grep will only match
          up to the first null; if it matches, it will print the
          entire line.


















































     Page 3                                        (last mod. 1/16/87)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026