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

前端 未结 5 2120
眼角桃花
眼角桃花 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:27

    Here is a suggestion:

    while read -n 1 c
    do
        echo "$c"
    done < "$INPUT_FILE" | grep '[[:alpha:]]' | sort | uniq -c | sort -nr
    

提交回复
热议问题