grep -o "string" infile | wc -w
The above oneliner also counts multiple occurences of the string on the same line(s).
If that is not needed (string only occurs once on every line):
grep -c "string" infile
Hope this helps.
Last edited by druuna; 06-24-2006 at 04:32 PM.