[Linux-disciples] grep more than one phrase
Jamie Forrest
jaf at honksandsirens.com
Wed Apr 23 12:45:15 EDT 2008
Those will do, thanks!
Jamie
On Apr 23, 2008, at 12:41 PM, Adam Rosi-Kessel wrote:
> Jamie Forrest wrote, on 4/23/2008 12:08 PM:
>> is there a way to grep for more than one phrase? or maybe i should
>> use
>> a different util for that?
>>
>> in other words i want to do something like:
>>
>> grep -r foo bar ~/public_html
>
> Do you mean grep for both or either?
>
> grep -r "foo\|bar" ~/public_html
>
> will show all hits with *either* "foo" or "bar"
>
> grep -r "foo.*bar" ~/public_html
>
> will show all hits with "foo" before "bar" in the same line
>
> grep -r "bar.*foo" ~/public_html
>
> will show all hits with "bar" before "foo" in the same line
>
> grep -r "\(bar.*foo\)\|\(foo.*bar\)" ~/public_html
>
> will show all hits with bar and foo on the same line in any order
>
> If you are getting more complex than that, you should probably use
> perl.
> _______________________________________________
> Linux-disciples mailing list
> Linux-disciples at lists.bostoncoop.net
> http://lists.bostoncoop.net/mailman/listinfo/linux-disciples
>
More information about the Linux-disciples
mailing list