Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!usc!ucsd!chem.ucsd.edu!tps From: tps@chem.ucsd.edu (Tom Stockfisch) Newsgroups: comp.unix.wizards Subject: serious awk bug Keywords: awk Message-ID: <702@chem.ucsd.EDU> Date: 14 Mar 90 06:02:46 GMT Reply-To: tps@chem.ucsd.edu (Tom Stockfisch) Organization: Chemistry Dept, UC San Diego Lines: 49 The following awk script doesn't behave properly: #! /bin/sh awk '/^a*[^b]/ { print "1:", $0 } /^a*b/ { print "2:", $0 } ' When given the following input b ab It produces the following output 2: b 1: ab 2: ab Basically, the line "ab" should match only rule 2, but it matches both rules. The following script: #! /bin/sh awk '/^a*[^b]c/ { print "1:", $0 } /^a*bc/ { print "2:", $0 } ' works, producing the output 2: bc 2: abc The corresponding lex program works fine. I have run the awk script with both the new awk and old awk, on both a system V machine (silicon graphics iris) and a 4BSD machine (celerity) and all seem to fail. -- || Tom Stockfisch, UCSD Chemistry tps@chem.ucsd.edu