BEGIN { RS="[ \t\n]+" } { count[$0]++ } # we are cheating and piping through sort(1) # because awk does not have a built-in sorting function END { sort = "sort -k 2nr" for (i in count) print i "\t" count[i] | sort close(sort) }