Bash script to find the frequency of every letter in a file

SkypeMeSM picture SkypeMeSM · Oct 19, 2010 · Viewed 16.6k times · Source

I am trying to find out the frequency of appearance of every letter in the english alphabet in an input file. How can I do this in a bash script?

Answer

dogbane picture dogbane · Oct 19, 2010

My solution using grep, sort and uniq.

grep -o . file | sort | uniq -c

Ignore case:

grep -o . file | sort -f | uniq -ic