Proofreading documents with awk
Gunter Steinbach
steinbac at hpl-opus.HP.COM
Sat Dec 16 17:38:40 AEST 1989
> / hpl-opus:comp.unix.questions / heit at meme.Stanford.EDU (Evan Heit) /
> 3:57 pm Dec 15, 1989 /
> I am looking for someone who has written a program in awk that will
> will allow me to proofread my papers by by looking for word repetitions.
How about this awk script:
awk '{p=0 # use a flag to avoid one line multiple times
if($1==last) {p=1; print NR-1 ": " last} # to catch doubles across lines
for(f=2;f<=NF;f++) if($f==$(f+1)) p=1
if(p==1) print NR ": " $0
last=$NF}'
This is the output when run on your original note:
15: will
16: will allow me to proofread my papers by by looking for word repetitions.
Good enough?
Guenter Steinbach gunter_steinbach at hplabs.hp.com
More information about the Comp.unix.questions
mailing list