#!/usr/bin/awk -f { split($0,line,"[^a-zA-Z]+") for ( x in line ) if ( line[x] ) word[line[x]]++} END { for ( x in word ) print x " appeared " word[x] " " adds(word[x]) | "sort -k3 -gr" } function adds(n) { return n==1 ? "time" : "times" }