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 $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]>wrote:
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 | TWikiGuest | view | TWiki.TWikiTutorial |
Mozilla |
10.88.68.26 |
| 15 Sep 2008 - 06:42 | TWikiGuest | view | TWiki.TWikiUsersGuide
|
Mozilla
| 10.88.68.26 |
| 15 Sep 2008 - 06:42 | TWikiGuest | view | TWiki.TWikiFAQ |
Mozilla
|
10.88.68.26 |
| 15 Sep 2008 - 06:44 | TWikiGuest | view | TWiki.ATasteOfTWiki |
Mozilla |
10.88.68.26 |
| 15 Sep 2008 - 06:46 | TWikiGuest | view | TWiki.WebHome |
Mozilla |
10.88.68.26 |
| 16 Sep 2008 - 04:06 | KailasMhase | save | Main.TestNewGroup |
|
10.88.68.26 |
| 16 Sep 2008 - 04:30 | TWikiGuest | view | Main.WebHome |
Mozilla |
10.77.224.12 |
| 16 Sep 2008 - 04:30 | TWikiGuest | view | TWiki.WebHome |
Mozilla |
10.77.224.12 |
| 16 Sep 2008 - 04:30 | TWikiGuest | view | TWiki.InstalledPlugins
|
Mozilla | 10.77.224.12 |
| 16 Sep 2008 - 04:30 | TWikiGuest | view |
TWiki.SpreadSheetPlugin |
Mozilla | 10.77.224.12 |
| 16 Sep 2008 - 04:32 | TWikiGuest | view | TWiki.TwistyPlugin |
Mozilla
|
10.77.224.12 |
| 16 Sep 2008 - 04:32 | TWikiGuest | view | TWiki.WebHome |
Mozilla |
10.77.224.12 |
| 16 Sep 2008 - 04:32 | TWikiGuest | view | TWiki.InstalledPlugins
|
Mozilla | 10.77.224.12 |
| 16 Sep 2008 - 04:33 | TWikiGuest | view | TWiki.SlideShowPlugin
|
Mozilla
| 10.77.224.12 |
| 16 Sep 2008 - 04:34 | TWikiGuest | view | TWiki.InstalledPlugins
|
Mozilla | 10.77.224.12 |
| 16 Sep 2008 - 04:50 | TWikiGuest | view | TWiki.InstalledPlugins
|
Mozilla | 10.88.68.26 |
| 17 Sep 2008 - 04:54 | TWikiGuest | view | TWiki.TWikiFuncDotPm |
Mozilla
| 10.88.68.26 |
How can I get the last entry of this file?(highlighted in blue)
my $last_line;
while( <> ){
$last_line = $_;
}
--
Just my 0.00000002 million dollars worth,
Shawn
"Where there's duct tape, there's hope."
Cross Time Cafe
"Perl is the duct tape of the Internet."
Hassan Schroeder, Sun's first webmaster
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
[Stewart Anderson]
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?
Information in this email including any attachments may be privileged,
confidential and is intended exclusively for the addressee. The views expressed
may not be official policy, but the personal views of the originator. If you
have received it in error, please notify the sender by return e-mail and delete
it from your system. You should not reproduce, distribute, store, retransmit,
use or disclose its contents to anyone. Please note we reserve the right to
monitor all e-mail communication through our internal and external networks.
SKY and the SKY marks are trade marks of British Sky Broadcasting Group plc and
are used under licence. British Sky Broadcasting Limited (Registration No.
2906991), Sky Interactive Limited (Registration No. 3554332), Sky-In-Home
Service Limited (Registration No. 2067075) and Sky Subscribers Services Limited
(Registration No. 2340150) are direct or indirect subsidiaries of British Sky
Broadcasting Group plc (Registration No. 2247735). All of the companies
mentioned in this paragraph are incorporated in England and Wales and share the
same registered office at Grant Way, Isleworth, Middlesex TW7 5QD.