#!/usr/bin/awk -f
{
$0 = tolower($0) # remove case distinctions
# remove punctuation
gsub(/[^[:alnum:]_[:blank:]]/, " ", $0)
for (i = 1; i <= NF; i++)
freq[$i]++
}
END {
sort = "sort -nr"
for (word in freq)
printf "%d\t%s\n", freq[word], word | sort
close(sort)
}
Add a code snippet to your website: www.paste.org