You can use grep -oto show exact matches, and then count them:
grep -o "word" filename.txt | wc -l
Test
$ cat a
hello hello how are you
hello i am fine
but
this is another hello
$ grep -c "hello" a
3
$ grep -o "hello" a
hello
hello
hello
hello
$ grep -o "hello" a | wc -l
4
source
share