Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!topaz!ll-xn!mit-amt!mit-eddie!genrad!decvax!bellcore!ulysses!burl!clyde!watmath!sunybcs!forys From: forys@sunybcs.UUCP (Jeff Forys) Newsgroups: net.unix-wizards Subject: Re: awk oddity: 2.8BSD vs. ULTRIX Message-ID: <964@sunybcs.UUCP> Date: Sat, 20-Sep-86 16:13:28 EDT Article-I.D.: sunybcs.964 Posted: Sat Sep 20 16:13:28 1986 Date-Received: Tue, 23-Sep-86 06:02:54 EDT References: <268@uwmacc.UUCP> Reply-To: forys@sunybcs.UUCP (Jeff Forys) Distribution: net Organization: SUNY/Buffalo Computer Science Lines: 31 Summary: merely a propagating bug... > When I type this [edited] command: > > awk '{ $1 = $2 + $3; print $0 }' > 1 1 1 1 > > I get these responses: > 2 1 1 1 on 2.8BSD on an 11/70, and > 1 1 1 1 on ULTRIX 32m v. 1.1 on a MicroVax II > and on 4.2BSD on a Vax 780. > > Why does awk vary in its response? It's just a bug in 4.2 awk and isn't dependant on machine type. Since DEC wanted ULTRIX 1.1 identical to 4.2, they retained the bug. :-) I don't know who fixed it under 2.8, but it has also been fixed (well, to this extent anyways) in 4.3. You can, of course, do either: print $1, $2, $3, $4 # and the results will be correct or, more portably (i usurped this from John Pierce's Supp. Doc for awk): output = $1 # Concatenate output fields for (i = 2; i <= NF; ++i) # into a single output line output = output OFS $i # with OFS between fields. print output I'll mail you a copy of the supplemental document for awk, Jeff. If anyone else wants one, send me mail (yeah I know, that was dumb ;-). --- Jeff Forys @ SUNY/Buffalo Computer Science (716-636-3004) Forys@Buffalo.CSNET -or- ..!{watmath|decvax|kitty}!sunybcs!forys