Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ grep(1) — DG/UX R4.11

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ed(1)

egrep(1)

fgrep(1)

sed(1)

sh(1)



grep(1)                          DG/UX R4.11                         grep(1)


NAME
       grep - search a file for a pattern

SYNOPSIS
       grep [options] limitedregularexpression [file ...]

DESCRIPTION
       grep searches files for a pattern and prints all lines that contain
       that pattern.  grep uses internationalized simple ("limited") regular
       expressions (expressions that have string values that use a subset of
       the possible alphanumeric and special characters) like those used
       with ed(1) to match the patterns.  It uses a compact non-
       deterministic algorithm.

       Be careful using the characters $, *, [, ^, |, (, ), and \ in the
       limitedregularexpression because they are also meaningful to the
       shell.  It is safest to enclose the entire limitedregularexpression
       in single quotes '...'.

       If no files are specified, grep assumes standard input.  Normally,
       each line found is copied to standard output.  The file name is
       printed before each line found if there is more than one input file.

       Command line options are:

       -b    Precede each line by the block number on which it was found.
             This can be useful in locating block numbers by context (first
             block is 0).
       -c    Print only a count of the lines that contain the pattern.
       -i    Ignore upper/lower case distinction during comparisons. This is
             valid for single byte characters only.
       -h    Prevents the name of the file containing the matching line from
             being appended to that line.  Used when searching multiple
             files.
       -l    Print the names of files with matching lines once, separated by
             new-lines.  Does not repeat the names of files when the pattern
             is found more than once.
       -n    Precede each line by its line number in the file (first line is
             1).
       -s    Suppress error messages about nonexistent or unreadable files
       -v    Print all lines except those that contain the pattern.

   International Features
       grep can process characters from supplementary code sets, as well as
       ASCII characters.  Searches are performed on characters, not
       individual bytes.

       Within [] expressions, grep recognizes international regular
       expression constructs such as:

                   [.ch.]      multi-character collation symbol
                   [=c=]       collation-order equivalence class
                   [:alpha:]   character class

       These constructs are described in ed(1).

EXAMPLES
       $ grep root /etc/passwd
       Prints the lines in the file "/etc/passwd" that contain the login
       name "root".

       $ grep 'W[[:upper:]]' myfile
       Prints the lines in the file "myfile" that contain a 'W' followed by
       an upper-case letter.

       $ who | grep "xyz"
       Prints the name, terminal number, and time that the user with login
       name "xyz" logged in if "xyz" is logged in.  If "xyz" is not logged
       in, this command line prints nothing.

       $ grep rsh /etc/passwd|cut -d: -f5
       Searches the "/etc/passwd" file for users who run a restricted shell,
       rsh(1).  Then cut(1) prints the fifth field of every line that  grep
       identifies.  The fifth field contains the users' names.

SEE ALSO
       ed(1), egrep(1), fgrep(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).

NOTES
       Lines are limited to BUFSIZ characters; longer lines are truncated.
       BUFSIZ is defined in /usr/include/stdio.h.
       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.

       Attempting to grep a FIFO with no associated writer, will cause grep
       to hang awaiting input.


Licensed material--property of copyright holder(s)

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