Command Reference Guide

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man1/!!!intro.1
________________________________________________________________
___ ___
g
grep(1) grep(1)
-q (Quiet) Do not write anything to the standard output, regardless of matching
lines. Exit with zero status upon finding the first matching line. Overrides any
options that would produce output.
-s Error messages produced for nonexistent or unreadable files are suppressed.
-v All lines but those matching are printed.
-w Select only those lines containing matches that form whole words. The test is
that the matching substring must either be at the beginning of the line, or pre-
ceded by a non-word constituent character. Similarly, it must be either at the
end of the line or followed by a non-word constituent character. Word-constituent
characters are letters, digits, and the underscore.
-x (eXact) Matches are recognized only when the entire input line matches the fixed
string or regular expression.
The file name is output in all the cases in which output is generated if there are more than one input file,
unless the -h option is specified. 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 (...).
EXTERNAL INFLUENCES
Environment Variables
LANG determines the locale to use for the locale categories when both LC_ALL and the corresponding
environment variable (beginning with LC_) do not specify a locale. If LANG is not specified or is set to the
empty string, a default of C (see lang(5)) is used.
LC_ALL determines the locale to use to override any values for locale categories specified by the settings of
LANG or any environment variables beginningwith LC_.
LC_COLLATE determines the collating sequence used in evaluatingregular expressions.
LC_CTYPE determines the interpretation of text as single byte and/or multi-byte characters, the
classification of characters as letters, the case information for the -i option, and the characters matched
by character class expressions in regular expressions.
LC_MESSAGES determines the language in which messages are displayed.
If any internationalization variable contains an invalid setting, the commands behave as if all international-
ization variablesare set to C. See environ(5).
International Code Set Support
Single-byte and multi-byte character code sets are supported.
RETURN VALUE
Upon completion, grep returns one of the following values:
0 One or more matches found.
1 No match found.
2 Syntax error or inaccessible file (even if matches were found).
EXAMPLES
In the Bourne shell (sh(1)) the following example searches two files, nding all lines containing occurrences
of any of four strings:
grep -F ’if
then
else
fi’
file1 file2
Note that the single quotes are necessary to tell grep -F when the strings have ended and the file names
have begun.
For the C shell (see csh(1)) the following command can be used:
grep -F ’if\ then\ else\ fi’ file1 file2
To search a file named address containing the following entries:
Section 1340 2 HP-UX Release 11i: December 2000
___
___