sajad torkamani
cat myfile.txt | grep 'foo' -o | wc -l

This will print the number of times the string foo appears in myfile.txt. This is useful when you need to count string occurrences as part of some script.

Tagged: Unix