Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jan 2002 03:56:50 +0100
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        Drew Tomlinson <drew@mykitchentable.net>
Cc:        questions@freebsd.org
Subject:   Re: Regular Expression Syntax
Message-ID:  <20020117025650.GA83411@student.uu.se>
In-Reply-To: <000b01c19f00$d396db20$0301a8c0@bigdaddy>
References:  <000b01c19f00$d396db20$0301a8c0@bigdaddy>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jan 16, 2002 at 06:44:04PM -0800, Drew Tomlinson wrote:
> I've been beating my head and just can get the syntax of this right.
> This expression works:
> 
> blacklamb> pkg_info | egrep "portupgrade|cvsup" | awk '{print
> "pkg_deinstall " $1}'
> pkg_deinstall cvsup-16.1_3
> pkg_deinstall portupgrade-20011210
> 
> How can I get the opposite?  In other words, everything except cvsup
> or portupgrade?  I know about the ! and () for grouping but can't seem
> to get it in the right place.  Help.

I don't think the version of regular expressions used by [e]grep
supports any negation operator.  Regular expressions in general do not
have any "not" operator defined.  Some extended variants of regular
expressions (like that found in Perl which is so extended that it
actually no longer qualifies as 'regular' :-) ) does support that.

Now, for your problem there is a much easier solution.  Use the '-v'
option for egrep.
Quoting from the manpage for egrep(1):

       -v, --invert-match
              Invert  the sense of matching, to select non-match-
              ing lines.





-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020117025650.GA83411>