Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Extracting Log File data for a given date range

by Anonymous Monk
on Dec 15, 2011 at 21:51 UTC ( #943841=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Extracting Log File data for a given date range
in thread Extracting Log File data for a given date range

I had this problem before. I ended up writing a utility script I call 'grange' for 'grep a range'. It depends on the fact that I'm usually parsing logfiles so the dates are sequential. So I used the range operator .. to match lines between the start and end regexes. If that matches your situation, then here's the whole utility:

#!/usr/bin/perl -n BEGIN { print "Usage: $0 <start pattern> <end_pattern>\n" and exit unless +@ARGV == 2; $start = shift @ARGV; $end = shift @ARGV; } next if 1 .. /$start/; last if /$end/; print
HTH!


Comment on Re^3: Extracting Log File data for a given date range
Download Code
Replies are listed 'Best First'.
Re^4: Extracting Log File data for a given date range
by Anonymous Monk on Aug 28, 2012 at 08:56 UTC
    It's a great "fewliner", but won't work if there are no log lines for either start or end position.
      Sure it will

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2015-07-29 22:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls