NetBSD/gnu/dist/gawk/awklib/eg/prog/dupword.awk

17 lines
414 B
Awk
Raw Normal View History

1999-06-14 00:39:15 +04:00
# dupword --- find duplicate words in text
# Arnold Robbins, arnold@gnu.ai.mit.edu, Public Domain
# December 1991
{
$0 = tolower($0)
gsub(/[^A-Za-z0-9 \t]/, "");
if ($1 == prev)
printf("%s:%d: duplicate %s\n",
FILENAME, FNR, $1)
for (i = 2; i <= NF; i++)
if ($i == $(i-1))
printf("%s:%d: duplicate %s\n",
FILENAME, FNR, $i)
prev = $NF
}