From owner-freebsd-questions Wed Jan 16 18:56:58 2002 Delivered-To: freebsd-questions@freebsd.org Received: from maila.telia.com (maila.telia.com [194.22.194.231]) by hub.freebsd.org (Postfix) with ESMTP id 67BB837B405 for ; Wed, 16 Jan 2002 18:56:54 -0800 (PST) Received: from d1o913.telia.com (d1o913.telia.com [195.252.44.241]) by maila.telia.com (8.11.6/8.11.6) with ESMTP id g0H2uq729790 for ; Thu, 17 Jan 2002 03:56:53 +0100 (CET) Received: from falcon.midgard.homeip.net (h185n2fls20o913.telia.com [212.181.163.185]) by d1o913.telia.com (8.8.8/8.8.8) with SMTP id DAA07297 for ; Thu, 17 Jan 2002 03:56:52 +0100 (CET) Received: (qmail 83451 invoked by uid 1001); 17 Jan 2002 02:56:50 -0000 Date: Thu, 17 Jan 2002 03:56:50 +0100 From: Erik Trulsson To: Drew Tomlinson Cc: questions@freebsd.org Subject: Re: Regular Expression Syntax Message-ID: <20020117025650.GA83411@student.uu.se> Mail-Followup-To: Drew Tomlinson , questions@freebsd.org References: <000b01c19f00$d396db20$0301a8c0@bigdaddy> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000b01c19f00$d396db20$0301a8c0@bigdaddy> User-Agent: Mutt/1.3.25i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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. -- Erik Trulsson ertr1013@student.uu.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message