Re: grep

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

 



On Sun, January 30, 2005 1:48 pm, Bill Gradwohl said:

> 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?
>
> i.e. Find these lines
> cat dog bird
> bird dog cat
> dog cat bird
> etc.

# grep -E '(.*(bird|cat|dog)){3}'

Which demands that an enclosed item appear 3 times... which means

cat cat cat
dog bird dog
etc..

will also match, so it's not exactly what you're looking for.

Sean



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

  Powered by Linux