Re: [ILUG] Newbie Perl Question

From: Dave Rynne (dave at domain dspsrv.com)
Date: Thu 04 Oct 2001 - 12:20:28 IST


> And again, my shell wont do it !!!
>
> vweb$ cat 2001.log | perl -ne '/\/en\// && print'
> bash: cat: command not found
> vweb$
>
> Oh what fun !

You don't need cat - it's just extra typing ;)

>
> I think what I was doing was working ok, so I did a script :
>
> perl -e 'open(I,"/logs/access.www.nuvotem.com");while(<I>){print $_
> if($_=~/2001/);}' >/tmp/2001.log
> perl -e 'open(I,"/tmp/2001.log");while(<I>){print $_ if($_=~/GET\
> \/en\//);}' >/tmp/2001en.log
> gzip /tmp/2001.log
> gzip /tmp/2001en.log
>
> .. so this gives me manageable files to take down my 64K isdn line !
>
> Can I pipe the result of the first command into the second ? or can I match
> both terms in one ?
> i.e. Give me all the lines that have "2001" and "GET /en/" in them ?

Something along the lines of:
perl -ne '(/\/en\// && /2001/) && print' < /logs/2001.log
should do the trick..

Dave

>
> (Said he, polishing his newbie hat)
>
> Thanks for all the suggestions folks,
> Declan
> [NODIS]
>



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:12:30 GMT