Lesson 8 | The –c option to grep |
Objective | Use grep / Count number of lines matching pattern. |
–c option to grep
Use
grep
to count the number of lines matching a pattern.
You can use the
–c
option with
grep
to display the lines that match your search parameters.
Here is some information about
regular expression wildcards.
-C NUM
--context=[NUM]
(GNU Extension)
Print NUM lines (default 2) of output context.
`-c'
`--count'
Suppress normal output; instead print a count
of matching linesfor each input file.
With the `-v', `--invert-match' option,
count non-matching lines.
The next lesson demonstrates how to redirect output with the tee command[1].
coption grep - Exercise
[1]command: If set, holds the command passed to the shell with the -c option.