Re: grep

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jan 30, 2005 at 12:48:50PM -0600, Bill Gradwohl wrote:
> According to the grep man page:
> Grep understands two different versions of regular expression syntax:
> âbasicâ and âextended.â In GNU grep, there is no difference in 
> avail-
> able functionality using either syntax.
> 
> However, the following function differently:
> grep -G 'cat|dog|bird' filename (Basic)
> grep -E 'cat|dog|bird' filename (Extended)
> 
> Am I interpreting something incorrectly?

There's no difference in available functionality, but how you get to that
functionality differs -- in the "basic" case you'll have to use \| to make |
have a special meaning, and for "extended" you use the \ to *remove* the
special meaning.

> Does anyone know how to construct a regular expression or in any way get 
> a single grep execution to do an AND instead of an OR operation so that 
> it looks for more that one string and matches a line when ALL the items 
> exist on that line, and are possibly in RANDOM order?

Do you mind if it matches "cat cat cat", or most it be exactly all three? If
you need it to be each one exactly one time, it'll be much easier to just
invoke grep three times....

-- 
Matthew Miller            mattdm@xxxxxxxxxx        <http://www.mattdm.org/>
-->  Fedora Users & Developers Conference, hosted by Boston University  <--
February 18th, 2005                 <http://fedoraproject.org/wiki/FUDCon1>  


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux