Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!isgate!krafla!magnus From: magnus@rhi.hi.is (Magnus Gislason) Newsgroups: comp.unix.wizards Subject: Re: serious awk bug Keywords: awk Message-ID: <1579@krafla.rhi.hi.is> Date: 14 Mar 90 16:36:43 GMT References: <702@chem.ucsd.EDU> Organization: University of Iceland Lines: 16 tps@chem.ucsd.edu (Tom Stockfisch) writes: >The following awk script doesn't behave properly: >#! /bin/sh >awk '/^a*[^b]/ { print "1:", $0 } >/^a*b/ { print "2:", $0 } >' [stuff deleted] >Basically, the line "ab" should match only rule 2, but it matches both >rules. The following script: In Regular Expressions `a*' meens 0 or more occurrencies of `a' and `[^b]' meens any character except `b'. In this case `a*[^b]' matches 0 `a's followed by a character that is not `b' (in this case `a'). I tried this with grep, egrep, sed and vi and they all behaved like awk so I suppose it's the correct way.