Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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
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 musing on the Monastery: (10)
As of 2014-09-16 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (48 votes), past polls