[wellylug] Some help with grep

Jamie Dobbs jamie.dobbs at orcon.net.nz
Tue Jun 22 10:42:20 NZST 2004


It almost seems to work.
Specifically what I am trying to do:

perl -ne 'print if
/Yes/&&/a.person at domain.co.nz|another.person at domain.co.nz|yet.another at domain.co.nz/'
< / file | wc -l

but this doesn't appear to work

So I want to search for the word yes and get all lines with that word and
any of the email addresses listed (this is because some people have
multiple email addresses and I need to parse the log to find details to
all addresses that the person might have.).

I got it working with multiple greps, put thought it might be cleaner in
Perl.

Thanks for your help, hopefully I can find a way to get this to work.

> Something like
>
> perl -ne 'print if /Yes/ && /word1|word2|work3/ ' < file
>
> might work. It does in my little test, assuming that I understand what
> you are trying to do.
>
> Cheers,
>
> Cliff
>
> On Tue, 22 Jun 2004 09:01:49 +1200 (NZST), you wrote:
>
>>Thanks for that. Another question now :-)
>>I'm pretty much a Perl newbie and would like to do a search similar to
>>this but use logic like thisL
>>
>>find any occurance of the word 'Yes', then on the same line any occurance
>>of the word 'word1' or the word 'word2' or word 'word3' etc.
>>
>>I've tried various options that I could think of but obviously Perl
>>doesn't like the way I think!
>>
>>
>>>
>>> Use perl if you want just one command, instead of grep and grep -V:
>>>
>>>     perl -ne 'print if /@domain.co.nz/&&!/this_address at domain.co.nz/' <
>>> file
>
>
> --
> Wellington Linux Users Group Mailing List: wellylug at lists.naos.co.nz
> To Leave:  http://lists.naos.co.nz/mailman/listinfo/wellylug
>
>





More information about the wellylug mailing list