Gentoo Archives: gentoo-admin

From: Lares Moreau <lares.moreau@×××××.com>
To: gentoo-admin@l.g.o
Subject: Re: [gentoo-admin] system audit
Date: Sat, 24 Dec 2005 22:36:48
Message-Id: 1135463679.7377.9.camel@localhost
In Reply to: Re: [gentoo-admin] system audit by "J.A."
On Sat, 2005-12-24 at 11:58 -0800, J.A. wrote:
> Any regex containing ! or | operators seem to get > interpreted by bash as a bash operator. This could > be avoided by putting the regex into a (perl?) file > but then I would have to memorize a bunch of stupid > little file scripts or create a stupid little file > containing the script every time. > > Here is one little example that doesn't work: > > # Filter everything except lines containing > # token1 or token2 > locate something | grep token1|token2 > > # Do not display lines with token3: > locate something | grep !token3 > > grep has a -v option which is the same as a regex > !token3 but I can't figure out how to then get grep > to recognize inverting more than one token such as > !(token3|token4).
! and | are bash operators, you need to escape them unless they are inside single-quotes. IIRC double quotes are interpeted by most shells, and single quotes arn't. # whatever | egrep 'token1|token2' or # whatever |egrep token1\|token2 # whatever | grep \!token or # whatever |grep '!token' I like egrep over grep. I like regexp. -Lares -- Lares Moreau <lares.moreau@×××××.com> | LRU: 400755 http://counter.li.org lares/irc.freenode.net | Gentoo x86 Arch Tester | ::0 Alberta, Canada Public Key: 0D46BB6E @ subkeys.pgp.net | Encrypted Mail Preferred Key fingerprint = 0CA3 E40D F897 7709 3628 C5D4 7D94 483E 0D46 BB6E

Attachments

File name MIME type
signature.asc application/pgp-signature