OT: perl vs shell cmd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Supose I want to parse a big log file (~500MB/4mil lines), which one is faster and use less memory:



$ ./parser.pl logfile.log

or

$ grep 'Jun 14 03:' | ./parser.pl

Log file is 24 hours and it will be processed every hour.

------
parser.pl:
$in_time = 'Jun 14 03:';

while(<>)
{
   if(/^$in_time/ {
      # do some processing
   }else {
      next;
   }
}


--

--beast


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux