Count the number of times a word appears in a file
LinuxFileLinux Problem Overview
What is an easy way to count the number of times a word appears in a file?
Linux Solutions
Solution 1 - Linux
This will also count multiple occurrences of the word in a single line:
grep -o 'word' filename | wc -l
Solution 2 - Linux
cat filename | tr ' ' '\n' | grep 'word' | wc -l
Solution 3 - Linux
fgrep "word to be counted" filename|wc -w