Re: [ILUG] Newbie Perl Question

From: Aidan Kehoe (kehoea at domain parhasard.net)
Date: Thu 04 Oct 2001 - 12:20:39 IST


$ perl -ne '/2001.*\/en\// && print' < 2001.log

You don't need cat here. That line assumes lines with the 2001 before
the /en/, though.

 Ar an 4u la de mi 10, scriobh Declan Grady :

> And again, my shell wont do it !!!
>
> vweb$ cat 2001.log | perl -ne '/\/en\// && print'
> bash: cat: command not found
> vweb$
>
> Oh what fun !
>
> 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 ?
>
> (Said he, polishing his newbie hat)
>
> Thanks for all the suggestions folks,
> Declan
> [NODIS]

-- 
`... when the elephant man broke strong men's necks, when he'd had too 
many Powers, ...'


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