Re: [Nolug] grepping multiple strings

From: Andrew S. Johnson <andy_at_asjohnson.com>
Date: Mon, 3 Mar 2003 12:52:57 -0600
Message-Id: <200303031252.57732.andy@asjohnson.com>

On Monday 03 March 2003 12:38 pm, Scott Harney wrote:
> "Andrew S. Johnson" <andy@asjohnson.com> writes:
>
> >> Thanks. I wonder why egrep doesn't have an "and" operator also. That
> >> seems like a big oversight.
> >
> > Actually, you could include a wildcard ".*" in your search string, which means
> > any number of any characters match. Try this: egrep "this.*that" filenames.
> > Isn't this AND?
>
> Not exactly. The words must be in the given order. In other words,
> you'll catch "this and that" but not "that and this" in our example.
> I figure he wants a true 'and' where both terms are captured
> regardless of the order. But don't believe me; try it!

How about egrep "this.*that|that.*this". Worked for me.

Andy Johnson

___________________
Nolug mailing list
nolug@nolug.org
Received on 03/03/03

This archive was generated by hypermail 2.2.0 : 12/19/08 EST