I would like to find out the number of occurrences of each of the alphabets in a word. Eginputaabbbddd outputa@2 b@3 c@0 d@3How can I perform this using shell script?
Number of occurences of letters in a word?
bash;shell;shell script
These solutions are case-insensitive:start cmd:> echo aabbbddd |   awk -v FS= '{for (i=1;i<=NF;i++) a[tolower($i)]++;};     END {for (key in a) print key :  a[key];}'a: 2b: 3d: 3Or for the complete alphabet:start cmd:> echo Aabbbddd |   awk -v FS= '{for (i=1;i<=NF;i++) a[tolower($i)]++;};    END {chars=abcdefghijklmnopqrstuvwxyz;    for (i=1;i<27;i++) { key=substr(chars,i,1);print key :  a[key]};}'a: 2b: 3c: d: 3e: f: g: h: i: j: k: l: m: n: o: p: q: r: s: t: u: v: w: x: y: z: