The grep(1) utilities search the given input files,
selecting lines that match one or more patterns; the type of
patterns is controlled by the options specified. It is not
considered an error if file is a file of type directory and
no warning will be printed. By default, a pattern matches an input
line if any regular expression (RE) in the pattern matches the
input line without its trailing newline. A null RE matches every
line. Each input line that matches at least one of the patterns is
written to the standard output.
For simple patterns or ex(1)- or ed(1)-style
regular expressions (basic regular expressions, described in the
Interix User's Guide), use the grep(1) utility. To
use extended regular expressions, use the -E flag, or invoke
the program as egrep(1). To search for a fixed string
instead of a pattern, use the -F flag, or invoke the command
as fgrep(1). A fixed string is a string of characters; each
character is matched only by itself.
Only a count of selected lines is written to standard
output.
-E
Use extended regular expressions. Cannot be used
with-F.
-eexpression
Specify a pattern used during the search of the input. Multiple
-e options can be used to specify multiple patterns; an
input line is selected if it matches any of the specified
patterns.
-F
Search for a fixed string rather than a regular expression.
Cannot be used with -E.
-fpattern_file
The pattern is read from the file named by the path name
pattern_file. Trailing newlines in the pattern_file are
ignored.
-h
Suppress file names in output. Usually, if more than one file
is searched, grep(1) prints the file name before printing
the matched line. This option suppresses that behavior.
-i
The case of letters is ignored in making comparisons; uppercase
and lowercase letters are considered identical.
-l
List only the names of the files containing lines that match.
Path names are listed once per file searched. If the standard input
is searched, the path name stdin is written. Useful for command
lines such as the following:
vi 'grep -l -e "[Ee]xactly" *.txt'
-n
Write the line number before each line of output; the first
line in each file is 1 even if multiple files are specified.
-o
Force file names in output. Usually, if more than one file is
searched, grep(1) prints the file name before printing the
matched line. This option forces the file name to be printed even
if only one file is searched. For standard input, grep(1)
prints "(standardinput):".
-q
Quiet: write nothing to standard output and exit with 0 if a
line is selected.
-s
Silent mode. Suppress error messages ordinarily written for
nonexistent or unreadable files. Other error messages are not
suppressed.
-v
Selected lines are those not matching the specified
patterns.
-x
"Exact" matching: the fixed string or the regular expression
must match the entire line before it is considered a match. For
example, the string "abc" matches a line that contains only "abc"
but not a line that contains "abcd".
If no file arguments are specified, the standard input is
used.