Re: Get the last entry of log file

2008-09-23 Thread Olteanu Eugen
Maybe this helps : tail -1 file and redirect the output to a file. On Mon, Sep 22, 2008 at 10:46 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: > Mr. Shawn H. Corey wrote: > >> On Wed, 2008-09-17 at 13:18 +0100, Stewart Anderson wrote: >> >>> How about a system(tail -x inputfile >> mylastfile)

Re: Get the last entry of log file

2008-09-22 Thread John W. Krahn
Mr. Shawn H. Corey wrote: On Wed, 2008-09-17 at 13:18 +0100, Stewart Anderson wrote: How about a system(tail -x inputfile >> mylastfile)type call to get the last line and then open the mylastfile to work on the line there? The UNIX utility tail(1) still reads the entire file. The

Re: Get the last entry of log file

2008-09-17 Thread John W. Krahn
Manasi Bopardikar wrote: I have a log file- [ snip ] How can I get the last entry of this file? use File::ReadBackwards; my $bw = File::ReadBackwards->new( 'log_file' ) or die "can't read 'log_file' $!"; my $last_line = $bw->readline; John -- Perl isn't a toolbox, but a small machine

RE: Get the last entry of log file

2008-09-17 Thread Mr. Shawn H. Corey
On Wed, 2008-09-17 at 13:18 +0100, Stewart Anderson wrote: > How about a system(tail -x inputfile >> mylastfile)type call to > get the last line and then open the mylastfile to work on the line > there? > The UNIX utility tail(1) still reads the entire file. -- Just my 0.0002 mil

Re: Get the last entry of log file

2008-09-17 Thread Mr. Shawn H. Corey
On Wed, 2008-09-17 at 13:55 +0200, Rob Coops wrote: > my $last_line; > while( <> ){ > $last_line = $_; > } > > Sure... depends on the size of the log, though. Do that for a log that > is > say 500MB in size and you are in for quite a wait as it will loop over > each > line in the file will it not

Re: Get the last entry of log file

2008-09-17 Thread Hridyesh Pant
try this... perl -ne'$l = $_; END { print $l }' /tmp/1.txt --Hridyesh Stewart Anderson wrote: From: Rob Coops [mailto:[EMAIL PROTECTED] Sent: 17 September 2008 12:55 To: Mr. Shawn H. Corey Cc: Manasi Bopardikar; beginners@perl.org Subject: Re: Get the last entry of log file my

RE: Get the last entry of log file

2008-09-17 Thread Stewart Anderson
> From: Rob Coops [mailto:[EMAIL PROTECTED] > Sent: 17 September 2008 12:55 > To: Mr. Shawn H. Corey > Cc: Manasi Bopardikar; beginners@perl.org > Subject: Re: Get the last entry of log file > > my $last_line; > while( <> ){ > $last_line = $_; > } > &

Re: Get the last entry of log file

2008-09-17 Thread Rob Coops
my $last_line; while( <> ){ $last_line = $_; } Sure... depends on the size of the log, though. Do that for a log that is say 500MB in size and you are in for quite a wait as it will loop over each line in the file will it not? On Wed, Sep 17, 2008 at 1:46 PM, Mr. Shawn H. Corey <[EMAIL PROTECTED

Re: Get the last entry of log file

2008-09-17 Thread Mr. Shawn H. Corey
On Wed, 2008-09-17 at 15:41 +0530, Manasi Bopardikar wrote: > I have a log file- > > | 15 Sep 2008 - 06:37 | TWikiGuest | view | TWiki.WebHome | Mozilla | > 10.88.68.26 | > > | 15 Sep 2008 - 06:37 | TWikiGuest | view | TWiki.TWikiFAQ | Mozilla | > 10.88.68.26 | > > | 15 Sep 2008 - 06:38 | TWik

Re: Get the last entry of log file

2008-09-17 Thread Rob Coops
m/([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/ Should do the trick I guess of course there are fancier ways but this will do the trick... Regards, Rob On Wed, Sep 17, 2008 at 12:11 PM, Manasi Bopardikar < [EMAIL PROTECTED]> wrote: > I have a log file- > > | 15 Sep 2008 - 06:37 | TWiki

Get the last entry of log file

2008-09-17 Thread Manasi Bopardikar
I have a log file- | 15 Sep 2008 - 06:37 | TWikiGuest | view | TWiki.WebHome | Mozilla | 10.88.68.26 | | 15 Sep 2008 - 06:37 | TWikiGuest | view | TWiki.TWikiFAQ | Mozilla | 10.88.68.26 | | 15 Sep 2008 - 06:38 | TWikiGuest | view | TWiki.TWikiTutorial | Mozilla | 10.88.68.26 | | 15 Sep 2008