kjepo@senilix.liu.se (Kjell Post) (02/28/88)
Recently, Alfred Aho and Ravi Sethi wrote an article in Software, Practice & Experience about maintaining cross references in manuscripts. The article contained the following script: grep -h "^\.@tag" sample | awk ' { print "s/" $3 "/" ++value[$2] "/g" } END { print "/^\\.@tag/d" } ' > xref.script sed -f xref.script sample > out However, the "/" after $3 never came out. 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). -- ------------------------------------------------------------------------------- (Y F) = (F (Y F)) |Dept of Comp&Info Science, Linkoping Sweden "This super-amazing, clever thing" | kjepo@majestix.liu.se - G.J. Sussman | ...liuida!majestix.liu.se!kjepo
dean@devvax.JPL.NASA.GOV (Dean Okamura) (03/02/88)
<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.
lm@arizona.edu (Larry McVoy) (03/02/88)
In article <729@senilix.liu.se> kjepo@senilix.liu.se (Kjell Post) writes: >For some reason, inserting 'foo' after the "/" did the trick: > > grep -h "^\.@tag" sample | awk ' > { print "s/" $3 "/" foo ++value[$2] "/g" } Oh yeah, I remember this one. One of the authors was feeling playful and added a variable "bar" to the source code of awk. The print routine has this line <if (!strcmp(bar, "foo")) goto tryagain>. Apparently, he liked the variable foo. Really. :-) :-) :-) -- Larry McVoy lm@arizona.edu or ...!{uwvax,sun}!arizona.edu!lm