Blame test/longwrds.awk

Packit 575503
# From Gawk Manual modified by bug fix and removal of punctuation
Packit 575503
Packit 575503
# Invoker can customize sort command if necessary.
Packit 575503
BEGIN {
Packit 575503
	if (!SORT) SORT = "LC_ALL=C sort"
Packit 575503
}
Packit 575503
Packit 575503
# Record every word which is used at least once
Packit 575503
{
Packit 575503
	for (i = 1; i <= NF; i++) {
Packit 575503
		tmp = tolower($i)
Packit 575503
		if (0 != (pos = match(tmp, /([[:lower:]]|-)+/)))
Packit 575503
			used[substr(tmp, pos, RLENGTH)] = 1
Packit 575503
	}
Packit 575503
}
Packit 575503
Packit 575503
#Find a number of distinct words longer than 10 characters
Packit 575503
END {
Packit 575503
	num_long_words = 0
Packit 575503
	for (x in used) 
Packit 575503
		if (length(x) > 10) {
Packit 575503
			++num_long_words
Packit 575503
			print x | SORT
Packit 575503
		}
Packit 575503
	print(num_long_words, "long words") | SORT
Packit 575503
	close(SORT)
Packit 575503
}