17 lines
347 B
Awk
17 lines
347 B
Awk
|
# wordfreq.awk --- print list of word frequencies
|
||
|
|
||
|
{
|
||
|
$0 = tolower($0) # remove case distinctions
|
||
|
# remove punctuation
|
||
|
gsub(/[^[:alnum:]_[:blank:]]/, "", $0)
|
||
|
for (i = 1; i <= NF; i++)
|
||
|
freq[$i]++
|
||
|
}
|
||
|
|
||
|
END {
|
||
|
sort = "sort -k 2nr"
|
||
|
for (word in freq)
|
||
|
printf "%s\t%d\n", word, freq[word] | sort
|
||
|
close(sort)
|
||
|
}
|