ubuntu-buildroot/output/build/host-gawk-5.2.0/awklib/eg/prog/dupword.awk

22 lines
507 B
Awk
Raw Normal View History

2024-04-01 15:19:46 +00:00
# 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
}