22 lines
507 B
Awk
22 lines
507 B
Awk
|
# dupword.awk --- find duplicate words in text
|
||
|
#
|
||
|
# Arnold Robbins, arnold@skeeve.com, Public Domain
|
||
|
# December 1991
|
||
|
# Revised October 2000
|
||
|
|
||
|
{
|
||
|
$0 = tolower($0)
|
||
|
gsub(/[^[:alnum:][:blank:]]/, " ");
|
||
|
$0 = $0 # re-split
|
||
|
if (NF == 0)
|
||
|
next
|
||
|
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
|
||
|
}
|