Linux - How to count total number of occurrences of a string in a file?
The following command counts and displays the total number of occurrences of teh string 'string' in the file 'filename'.
grep -o 'string' filename | wc -l
The above command will count even the sub-strings. If you would like to count only full words then you can also use the following command.
grep -o '\bstring\B' filename | wc -l