Hi ya,

I'm teaching myself Perl and I have a log file around 1GB that I need to sort 
by month | date | time | byte size. So far I have parse the log for "bytes" 
since this is all that I need but I can't get it to sort like I want.

Here is the Data I parsed for bytes but now I need to sort by month | date | 
time | byte size.

Aug  3 04:02:02 node qmail: 1028545322.562816 info msg 401391: bytes 4138 
from <#@[]> qp 1367 uid 507
Aug  2 04:02:57 node qmail: 1028545377.266421 info msg 401390: bytes 614 
from <[EMAIL PROTECTED]> qp 1558 uid 0
Aug  1 04:02:57 node qmail: 1028545377.340607 info msg 401393: bytes 1206 
from <> qp 1561 uid 507
Aug  4 04:02:57 node qmail: 1028545377.423885 info msg 401391: bytes 1701 
from <#@[]> qp 1564 uid 507
Aug  5 04:02:02 node qmail: 1028545322.562816 info msg 401391: bytes 4138 
from <#@[]> qp 1367 uid 507
Aug  9 04:02:57 node qmail: 1028545377.266421 info msg 401390: bytes 614 
from <[EMAIL PROTECTED]> qp 1558 uid 0
Aug  7 04:02:57 node qmail: 1028545377.340607 info msg 401393: bytes 1206 
from <> qp 1561 uid 507
Aug  8 04:02:57 node qmail: 1028545377.423885 info msg 401391: bytes 1701 
from <#@[]> qp 1564 uid 507

CODE:

#!/usr/bin/perl

$hostname = `hostname`;
@a = localtime(time);
$today = sprintf("%04d/%02d/%02d",1900+$a[5], $a[4]+1, $a[3]);
print "Date: $today\n";
#Search current log file for "byte"
$log = "/var/log.txt";
print "Byte Statistics for HOST: $hostname\n";
open (FILE, "< $log")
        or die "Couldn't open $log!";
while ($line = <FILE>) {
    if ($line =~ /byte/i) { print $line }
}
close (FILE);

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to