Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!sdsu!ucsd!ucbvax!hplabs!hpl-opus!steinbac From: steinbac@hpl-opus.HP.COM (Gunter Steinbach) Newsgroups: comp.unix.questions Subject: Re: Proofreading documents with awk Message-ID: <63720018@hpl-opus.HP.COM> Date: 16 Dec 89 06:38:40 GMT References: <25@meme.stanford.edu> Organization: HP Labs, High Speed Electronics Dept., Palo Alto, CA Lines: 21 > / hpl-opus:comp.unix.questions / heit@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@hplabs.hp.com