Count occurrences of a char in plain text file

cupakob picture cupakob · Oct 21, 2009 · Viewed 92.4k times · Source

Is there any way under linux/terminal to count, how many times the char f occurs in a plain text file?

Answer

Cascabel picture Cascabel · Oct 21, 2009

How about this:

fgrep -o f <file> | wc -l

Note: Besides much easier to remember/duplicate and customize, this is about three times (sorry, edit! botched the first test) faster than Vereb's answer.