Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!elroy!devvax!dean From: dean@devvax.JPL.NASA.GOV (Dean Okamura) Newsgroups: comp.unix.questions Subject: Re: AWK Bug? Message-ID: <1430@devvax.JPL.NASA.GOV> Date: 1 Mar 88 16:10:16 GMT References: <729@senilix.liu.se> Reply-To: dean@devvax.JPL.NASA.GOV (Dean Okamura) Organization: Jet Propulsion Laboratory, Pasadena, CA. Lines: 25 Keywords: awk <729@senilix.liu.se> wrote that: > Recently, Alfred Aho and Ravi Sethi wrote an article in Software, > Practice & Experience about maintaining cross references in manuscripts. > > ... > > For some reason, inserting 'foo' after the "/" did the trick: > > grep -h "^\.@tag" sample | awk ' > { print "s/" $3 "/" foo ++value[$2] "/g" } > END { print "/^\\.@tag/d" } > ' > xref.script > sed -f xref.script sample > out > > This was on a Sun 3/50 running SunOS 3.2 (UNIX 4.2BSD). I encountered the same problem but I used parentheses around the ++value[$2] which looks a little better: { print "s/" $3 "/" (++value[$2]) "/g" } -- Dean Okamura Jet Propulsion Laboratory, M/S 301-260A, 4800 Oak Grove Drive, Pasadena, CA 91109, USA (818) 354-1490 Please send returned mail to dean@devvax.JPL.NASA.GOV. There seems to be mail problems with jpl-devvax.