home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
fish
/
telecom
/
uucp_442
/
uucp2.lzh
/
uucp2
/
man
/
Grep
< prev
next >
Wrap
Text File
|
1989-10-14
|
4KB
|
101 lines
NAME
grep, - search file for regular expression
SYNTAX
grep [option...] expression [file...]
DESCRIPTION
The grep command searchs the input files (standard input
default) for lines matching a pattern. Normally, each
line found is copied to the standard output. The grep com-
mand patterns are limited regular expressions in the style
of ex(1), which uses a compact nondeterministic algorithm.
In all cases the file name is shown if there is more than
one input file. Care should be taken when using the charac-
ters $ * [ ^ | ( ) and \ in the expression as they are also
meaningful to some Shells. It is safest to enclose the
entire expression argument in single quotes ' '.
A \ followed by a single character other than new line
matches that character.
The character ^ matches the beginning of a line.
The character $ matches the end of a line.
A . (period) matches any character.
A single character not otherwise endowed with special
meaning matches that character.
A string enclosed in brackets [] matches any single
character from the string. Ranges of ASCII character
codes may be abbreviated as in `a-z0-9'. A ] may occur
only as the first character of the string. A literal -
must be placed where it can't be mistaken as a range
indicator.
A regular expression followed by an * (asterisk)
matches a sequence of 0 or more matches of the regular
expression. A regular expression followed by a +
(plus) matches a sequence of 1 or more matches of the
regular expression. A regular expression followed by a
? (question mark) matches a sequence of 0 or 1 matches
of the regular expression.
Two regular expressions concatenated match a match of
the first followed by a match of the second.
Two regular expressions separated by | or new line
match either a match for the first or a match for the
second.
A regular expression enclosed in parentheses matches a
match for the regular expression.
The order of precedence of operators at the same parenthesis
level is [] then *+? then concatenation then | and new line.
Ideally there should be only one grep, but we don't know a
single algorithm that spans a wide enough range of space-
time tradeoffs.
OPTIONS
-b Precedes each output line with its block number. This is
sometimes useful in locating disk block numbers by con-
text.
-c Produces count of matching lines only.
-e expression
Uses next argument as expression that begins with a minus
(-).
-i Considers upper and lowercase letter identical in making
comparisons.
-l Lists files with matching lines only once, separated by a
new line.
-n Precedes each matching line with its line number.
-s Silent mode and nothing is printed (except error mes-
sages). This is useful for checking the error status
-v Displays all lines that do not match specified expres-
sion.
-w Searches for an expression as for a word (as if sur-
rounded by `\<' and `\>').
RESTRICTIONS
Lines are limited to 256 characters; longer lines are trun-
cated.
DIAGNOSTICS
Exit status is 0 if any matches are found, 1 if none, 2 for
syntax errors or inaccessible files.