With recent versions ofThis unfortunately does not work with GNU coreutils,.
grep -o -c WORD file should work.If it works on your platform, it's an elegant and fairly intuitive solution; but (Earlier versions had a bug in this combination of options.)the GNU folks are still thinking.