Hi,
I have a log file which contains lines like below:
2010-07-19 07:13:19,021 ERROR system ...(text)
2010-07-19 07:22:03,427 ERROR system ...(text)
class com... (text)
2010-07-19 07:23:19,026 ERROR system ...(text)
class com... (text)
each line is a separate line... I am given the a
start time such as : "2010 07 17 07 13 19 "
end time such as: "2010 07 19 20 00 00"
and I have 2 variables which puts them to the format of "2010-07-19 07:13:19" and "2010-07-19 20:00:00
I'm not sure what to put such a search pattern to return the log lines in between (inclusive) the start and end times given, and on the example above, it should return lines afters it as well.
if I put the start time and end time of only the first time log line from above it should be:
2010-07-19 07:13:19,021 ERROR system ...(text)
if I put the start time and end time of only the second time log line from above it should be:
2010-07-19 07:22:03,427 ERROR system ...(text)
class com... (text)
if I put the start time and end time of only the third time log line from above it should be:
2010-07-19 07:23:19,026 ERROR system ...(text)
class com... (text)
or if i just put a start and end time including all it should return everything.. etc
This problem is kind of complicated... I would greatly appreciated if anyone can even lead me in the way of getting it to the correct search outputs.
Thanks
I have the following code which, only looks for the start time for exact matches, and returns.
awk -vs="$sstart" '$0~"^"s{p=1}!($0~"^"s) && /^2010/{if(p==1){print "\n"}p=o}p' "$f"
$sstart is the format of "2010-07-19 07:13:19", and $F is the file name.