Does grep offer a way to count the total number of matches it makes? The -c option only returns the number of lines that matched the regex, but in this case I have multiple matches per line.
migrated from stackoverflow.com Sep 25 '11 at 2:09
This question came from our site for professional and enthusiast programmers.
well, -E is just an example, it could be -P, -F etc. point is -o
There is a -o flag which indicates that only the matched subsection of the line should get printed.
Use that in conjunction with wc -l:
man grep explains it as well.