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]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux