Reputation: 1023
What is an easy way to count the number of times a word appears in a file?
Upvotes: 68
Views: 85076
Reputation: 4348
This will also count multiple occurrences of the word in a single line:
grep -o 'word' filename | wc -l
Upvotes: 151