print lines matching a pattern
|
--color[=WHEN], --colour[=WHEN]
Surround the matched (non-empty) strings, matching lines, context lines, file names, line numbers,
byte offsets, and separators (for fields and groups of context lines) with escape sequences to
display them in color on the terminal. The colors are defined by the environment variable
GREP_COLORS. The deprecated environment variable GREP_COLOR is still supported, but its setting
does not have priority. WHEN is never, always, or auto.
|
-m NUM, --max-count=NUM
Stop reading a file after NUM matching lines. If the input is standard input from a regular file,
and NUM matching lines are output, grep ensures that the standard input is positioned to just
after the last matching line before exiting, regardless of the presence of trailing context lines.
This enables a calling process to resume a search. When grep stops after NUM matching lines, it
outputs any trailing context lines. When the -c or --count option is also used, grep does not
output a count greater than NUM. When the -v or --invert-match option is also used, grep stops
after outputting NUM non-matching lines.
|
Context Line Control
-A NUM, --after-context=NUM
Print NUM lines of trailing context after matching lines. Places a line containing a group
separator (--) between contiguous groups of matches. With the -o or --only-matching option, this
has no effect and a warning is given.
|
grep searches the named input FILEs (or standard input if no files are named, or if a single hyphen-minus
(-) is given as file name) for lines containing a match to the given PATTERN. By default, grep prints
the matching lines.
|
Before a command is executed, its input and output may be redirected using a special notation interpreted
by the shell. Redirection may also be used to open and close files for the current shell execution
environment. The following redirection operators may precede or appear anywhere within a simple command
or may follow a command. Redirections are processed in the order they appear, from left to right.
Redirecting Output
Redirection of output causes the file whose name results from the expansion of word to be opened for
writing on file descriptor n, or the standard output (file descriptor 1) if n is not specified. If the
file does not exist it is created; if it does exist it is truncated to zero size.
The general format for redirecting output is:
[n]>word
If the redirection operator is >, and the noclobber option to the set builtin has been enabled, the
redirection will fail if the file whose name results from the expansion of word exists and is a regular
file. If the redirection operator is >|, or the redirection operator is > and the noclobber option to
the set builtin command is not enabled, the redirection is attempted even if the file named by word
exists.
|