Contents of the GREP.DOC file
grep - search a file for a pattern
grep [ options ] expression [ files ]
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. The following
options are recognized:
-x (Exact) only lines matched in their entirety are
-c Only a count of matching lines is printed.
-m Do not ignore upper/lower case distinction during
comparisons (default is ignore case).
-l Only the names of files with matching lines are listed
-n Each line is preceded by its relative byte number in
-s The error messages produced for nonexistent or
unreadable files are suppressed.
Same as a simple expression argument, but useful when
the expression begins with a "-".
The strings list is taken from the file.
Printing of the file names is suppressed.
In all cases, the file name is output if there is more than
one input file. It is safest to enclose the entire
expression argument in double quotes "...".
You may include more than one file specification on the
command line. For example
grep -m test *.c *.h
This will search all files in the default directory of the
form *.c and *.h for all occurrences of the word "test".
Exit status is 0 if any matches are found, 1 if none, 2 for
syntax errors or inaccessible files (even if matches were
Ideally grep would print the line number in which the string
was found. Because the Boyer-Moore algorithm (which uses a
skip pattern) is used this is not possible.