How can I use the UNIX shell to count the number of times a letter appears in a text file?

samoz picture samoz · Sep 2, 2009 · Viewed 76k times · Source

I have a few text files and I'd like to count how many times a letter appears in each?

Specifically, I'd like to use the UNIX shell to do this, in the form of: cat file | .... do stuff...

Is there a way I can get the wc command to do this?

Answer

SilentGhost picture SilentGhost · Sep 2, 2009
grep char -o filename | wc -l