in reply to Re: Extract lines between two values from file
in thread Extract lines between two values from file
This will still present a problem if there don't happen to be any events between 09:05:00 and 09:05:01, though. As choroba said, $start_point and $end_point have to appear literally at least once each in the file for pattern matching to work in this way. If $end_point is "09:05:00", it's not going to know to stop between lines having times of "09:04:59" and "09:05:01".
To make that work, you'll need to loop through the file, extracting the date/time and comparing it to $start_point until a line's date is greater than that value, then start processing lines and doing the same with $end_point until you hit a line with a date greater than $end_point, and then stop.
That also assumes that your log entries are always in date-order. That's usually true, but it's at least theoretically possible that different processes could write to the same log file slightly out of order, in which case you'd want to just check all times for being greater than $start_point and less than $end_point, and not worry about starting or stopping at certain lines.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Extract lines between two values from file
by plexy (Initiate) on Nov 08, 2011 at 14:42 UTC |