Count the number of times a word appears in a file

This will also count multiple occurrences of the word in a single line:

grep -o 'word' filename | wc -l

cat filename | tr ' ' '\n' | grep 'word' | wc -l