Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How do I read a log file that contents recurring log messages those are separated by newline characters?

by pileofrogs (Priest)
on Oct 14, 2010 at 19:16 UTC ( #865336=note: print w/ replies, xml ) Need Help??


in reply to How do I read a log file that contents recurring log messages those are separated by newline characters?

This is what perl is great for.

Probably the most direct approach would be to parse each line with a regex to get the parts you care about (IE not the timestamp). Create a hash where the key is the relevant part of the line and the value is a number that you increment every time you find the same message. Notice you're not keeping the whole file in memory, just one instance of each line and a number.

--Pileofrogs


Comment on Re: How do I read a log file that contents recurring log messages those are separated by newline characters?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://865336]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2014-12-26 18:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (174 votes), past polls