linux count occurrences of string in file code example
Example 1: count occurrences of word in unix bash
$ grep -o -i needs inspire.txt | wc -l
Example 2: count occurrences of word in file linux
grep -wc "your_text" FileName
Example 3: grep ocurrences
Just use flag -m to define number of occurrences to match:
grep -m1 pattern file