Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jan 2002 07:58:43 -0800
From:      "Drew Tomlinson" <drew@mykitchentable.net>
To:        <questions@freebsd.org>
Cc:        "Tony Landells" <ahl@austclear.com.au>, "Erik Trulsson" <ertr1013@student.uu.se>, "parv" <parv_@yahoo.com>, "Jim Conner" <jconner@enterit.com>, "Kent Stewart" <kstewart@owt.com>
Subject:   Re: Regular Expression Syntax - SOLVED
Message-ID:  <004f01c19f6f$d72336c0$c42a6ba5@lc.ca.gov>
References:  <000b01c19f00$d396db20$0301a8c0@bigdaddy>

next in thread | previous in thread | raw e-mail | index | archive | help
----- Original Message -----
From: "Drew Tomlinson" <drew@mykitchentable.net>
To: <questions@freebsd.org>
Sent: Wednesday, January 16, 2002 6:44 PM
Subject: Regular Expression Syntax


> 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.

Thank you to all that responded.  As in most cases, there are many ways
to accomplish this task.  These are the things I learned:

1.  There is not a "not" operator for the various "greps" in FBSD.  I
don't know about other *nixs but then this is a FBSD list so it really
doesn't matter.

2.  To use a "not", use the -v switch with grep as documented in the man
page.

3.  Parv pointed out that in this example, grep isn't needed as awk can
perform the "everything except this" function.  Here was his example:
pkg_info | awk '! /portupgrade|cvsup/ {print "pkg_deinstall " $1}'

4.  And finally, Kent Stewart figured out what I was attempting to do
and suggested deleting all packages, installing CVSUP from packages, and
then installing portupgrade and all of it's dependencies.

Thank you all for helping me learn to tie all of the basics together to
perform more complex commands.  Now I'm *REALLY* starting to understand
and appreciate the power of FBSD.

Drew


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?004f01c19f6f$d72336c0$c42a6ba5>