#!/bin/csh
# shell script version of commonest words homework task for comparative testing.
# determine the 5 commonest words in the standard input
# output 5 lines of
#    word ':' frequency-count
# cwj Jan 2008
# words are sequences of alphanumeric characters
#method: squash all whitespace
tr -cs '[:alnum:]' '\n' | tr 'A-Z' 'a-z' | sort | uniq -c \
 | sort -nr -k1 -k2 | head -5 | awk '{print $2 ": " $1}'

