#Pure Bash (no external programs), 164 This is longer than I'd hoped, but I wanted to see if the necessary counting and sorting (in the right direction) could be done purely with `bash` arrays (associative and non-associative): declare -A c for w in ${@//[[:punct:]]/ };{ ((c[$w]++));} for w in ${!c[@]};{ i=${c[$w]};((m=i>m?i:m));s[$i]+=$w:;} for((i=m;i>0;i--));{ printf "${s[i]//:/:$i }";} Save as a script file, `chmod +x`, and run: <pre> $ ./countoccur This is a text and a number: 31. a:2 and:1 number:1 text:1 31:1 is:1 This:1 $ </pre>