Re: Basic Grep Question

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

 



Dotan Cohen wrote:
From Dan's question, it appears that he wants AND behaviour, not OR
behaviour, from the two greps.

I had to look at it three times as well.

The command line amounts to "not cat and not gray" which is logically equivalent to "not (cat or gray)".

For the inverse (cat and gray), I would never have guessed at Marc's solution. I just use as many greps as needed.

If the OP's motive was efficiency, you're meowing up the wrong tree it seems:

$ time grep -P "(?=.*cat)(?=.*red)" /usr/share/dict/words | wc
     80      80    1082

real    0m0.400s
user    0m0.366s
sys     0m0.018s

$ time grep cat /usr/share/dict/words | grep red | wc
     80      80    1082

real    0m0.051s
user    0m0.017s
sys     0m0.019s

(sorry, there are no matches for cat and gray)

<Joe


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

  Powered by Linux