grep

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

 



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?

The command :
grep -E 'cat|dog|bird' filename
will output any line that contains cat OR dog OR bird or any combination.

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.

--
Bill Gradwohl
bill@xxxxxxx
http://www.ycc.com
spamSTOMPER Protected email


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

  Powered by Linux