User guide
grep
grep — search for regular expressions
Globally searches for regular expressions and prints any lines containing
occurrences of the regular expressions. A regular expression is a shorthand
way of specifying a wildcard type of string comparison. Since the grep command
is line oriented, it only works on ASCII files.
Syntax
grep [-c] [-i] [-n] [-v]
expression
-f
file
[
file1
][
file2
...]
Arguments
expression
Specifies the regular expression for which to search. If you include
metacharacters, enclose the expression within quotes to avoid interpretation
by the shell.
The grep command supports the following metacharacters:
^ Matches the beginning of a line.
$ Matches the end of a line.
. Matches any single character.
[] Matches a specified set of characters, for example, [ABC] matches A or B
or C.
The following rules also apply for these sets:
• A dash other than the first or last character denotes a range of
characters: [A-Z] matches any uppercase letter.
• If the first character of the set is ^, then the sense of match is
reversed: [^0-9] matches any non-digit.
• The following characters must be preceded with backslash (\ ) if they
occur in a set: \, ], -, and ^.
* Repeated matching.
When placed after a pattern, the asterisk indicates that the pattern
should match any number of times. For example, [a-z][0-9]* matches a
lowercase letter followed by zero or more digits.
13–52 Console Commands