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

前端 未结 5 2118
眼角桃花
眼角桃花 2021-02-06 23:26

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?

5条回答
  •  执念已碎
    2021-02-07 00:25

    My solution using grep, sort and uniq.

    grep -o . file | sort | uniq -c
    

    Ignore case:

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

提交回复
热议问题