Re: Search for two words in a File

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

 



At 2:52 PM +0100 4/26/06, Matt Davey wrote:
>On Wed, 2006-04-26 at 12:53 +0100, Paul Howarth wrote:
>> Tim wrote:
>> > On Wed, 2006-04-26 at 10:50 +0100, Paul Howarth wrote:
>> >> grep -E 'deep|html' test
>> >
>> > Wouldn't that match against *either* word, rather than require both to
>> > be present?
>>
>> Yes, but that's what I thought the OP was looking for.
>>
>> To look for both words in the same line, I'd use:
>>
>> $ grep deep test | grep html
>
>And to require both words to be present anywhere in the file you could
>use:
>
>grep -q deep test && grep -q html test && echo "found both"

Or searching a directory (/not/ what the OP asked for!):

    grep -rlZ deep dir/ | xargs -0 grep -l html
____________________________________________________________________
TonyN.:'                       <mailto:tonynelson@xxxxxxxxxxxxxxxxx>
      '                              <http://www.georgeanelson.com/>


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

  Powered by Linux