The wc (word count) command can be used to sum various bits of information about the searches we were undertaking using grep.
If we pipe the output of grep into wc, we are returned a line containing 3 tab separated numbers.
grep Chevy americanpie.txt | wc
7 77 358
The first number is the number of lines, the second the number of words and the third the total number of characters returned. This is a useful summary, but the individual numbers can be returned by adding an additional flag to the wc command.
To return the number of lines we can add the –l (lines) flag. To return the number of words, use the –w (words) flag. And for the number of characters use the –c (characters) flag.
grep Chevy americanpie.txt | wc –l
grep Chevy americanpie.txt | wc –w
grep Chevy americanpie.txt | wc –c