[wellylug] Some help with grep

Enkidu enkidu at cliffp.com
Sun Jun 20 10:57:29 NZST 2004


On Sun, 20 Jun 2004 09:35:07 +1200, you wrote:

>On Sunday 20 June 2004 09:30, Jamie Dobbs wrote:
>> Sunday, June 20, 2004, 9:18:26 AM, you wrote:
>>
>> JD> Is there any way with grep that I can search for certain instances of
>> JD> a string (in this case an email domain) but not include a certain
>> JD> address.
>>
>> JD> ie. I want to find all occurances of @domain.co.nz in the file but have
>> it ignore JD> any instances of this_address at domain.co.nz
>>
>> (but include all other email address in the domain in the search)
>
>You could use a pipe.
>
>$ grep "@domain.co.nz" somefile | grep -v "this_address at domain.co.nz"
>
>I haven't tested this. You might need to escape some of the characters.
>
The last bit could probably be grep -v "this_address" unless
"this_address" is common in the file. Intuitively, it would be faster,
if that matters.

Cheers,

Cliff




More information about the wellylug mailing list