[wellylug] Some help with grep
Rob Stockley
wellylug at mowgli.net.nz
Sun Jun 20 11:30:03 NZST 2004
On Sunday 20 June 2004 11:24, David Antliff wrote:
> On Sun, 20 Jun 2004, Jamie Dobbs wrote:
> > Is there any way with grep that I can search for certain instances of
> > a string (in this case an email domain) but not include a certain
> > address.
> >
> > ie. I want to find all occurances of @domain.co.nz in the file but have
> > it ignore any instances of this_address at domain.co.nz
>
> cat thefile | grep '@domain.co.nz' | grep -v 'this_address at domain.co.nz'
using cat first is almost always unnecessary in a pipe. Reduce the number of
key presses required by passing thefile directly to the first grep, ala
grep '@domain.co.nz' thefile | grep -v 'this_address at domain.co.nz'
I used cat all the time until I had this pointed out to me one day.
HTH,
Rob
More information about the wellylug
mailing list