I want to get the data between two times in a log file of different months and date.Suppose if my startime is not present in the logfile, then I want to extract the data from the nearest next time in the logfile. And also it has to end before the endtime, if the entered endtime is not present in the log file.
My log file data,
Apr 10 16 02:07:20 Data 1
Apr 11 16 02:07:20 Data 1
May 10 16 04:11:09 Data 2
May 12 16 04:11:09 Data 2
Jun 11 16 06:22:35 Data 3
Jun 12 16 06:22:35 Data 3
The solution I am using is,
awk -v start="$StartTime" -v stop="$EndTime" 'start <= $StartTime && $EndTime <= stop' $file
where, I am storing my starttime in $StartTime
and endtime in $EndTime
But Iam not getting the exact output. Please help.