Count all occurrences of a string in lots of files with grep
Solution 1:
This works for multiple occurrences per line:
grep -o string * | wc -l
Solution 2:
cat * | grep -c string
Solution 3:
grep -oh string * | wc -w
will count multiple occurrences in a line
Solution 4:
Instead of using -c, just pipe it to wc -l.
grep string * | wc -l
This will list each occurrence on a single line and then count the number of lines.
This will miss instances where the string occurs 2+ times on one line, though.