Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought



GREP(1)         DOMAIN/IX Reference Manual (SYS5)         GREP(1)



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

USAGE
     grep [ options ] expression [ files ]

     egrep [ options ] [ expression ] [ files ]

     fgrep [ options ] [ 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.  Patterns used
     by grep are limited regular expressions in the style of ed
     (1), using a compact nondeterministic algorithm.  Those used
     by egrep are full regular expressions, using a fast deter-
     ministic algorithm that sometimes needs exponential space.
     Patterns used by fgrep are fixed strings that are fast and
     compact.

     In all cases, the filename is output if there is more than
     one input file.  Be careful, however, when using any of the
     following characters in expression: $, *, [, ^, |, (, ), and
     \. These characters are also meaningful to the Shell.  It is
     safest to enclose an entire expression argument in single
     quotes ('...').

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

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

     1.    A regular expression followed by a plus sign (+)
           matches one or more occurrences of the regular expres-
           sion.
     2.    A regular expression followed by a question mark (?)
           matches zero or one occurrences of the regular expres-
           sion.
     3.    Two regular expressions separated by a pipe character
           (|) or by a new-line 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 as follows: brackets
     ([  ]), asterisk (*), question mark (?), plus sign (+), con-
     catenation, pipe (|), and newline.

OPTIONS
     -v             Print all lines except those that match.



Printed 6/10/85                                            GREP-1





GREP(1)         DOMAIN/IX Reference Manual (SYS5)         GREP(1)



     -x             Print only lines exactly matched (fgrep
                    only).

     -c             Print only a count of matching lines.

     -i             Ignore upper- and lowercase distinction dur-
                    ing comparisons.

     -l             List only the filenames with matching lines.
                    Separate the names with new-lines.

     -n             Precede each line by its relative line number
                    in the file.

     -b             Precede each line by the block number (1024
                    bytes per block) on which it was found.  Use-
                    ful in locating disk block numbers by con-
                    text.

     -s             Suppress the error messages produced for
                    nonexistent or unreadable files (grep only).

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

     -f file        Take the regular expression (egrep) or
                    strings list (fgrep) from the file.

CAUTIONS
     Lines are limited to BUFSIZ characters (defined in
     /usr/include/stdio.h); longer lines are truncated.

     Egrep does not recognize ranges, such as [a-z], in character
     classes.

     If a line is embedded with nulls, grep only matches up to
     the first null; if the null matches, grep prints the entire
     line.

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

RELATED INFORMATION
     ed (1), sed (1), sh (1).








GREP-2                                            Printed 6/10/85



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