I have a huge logfile inculding timestamp varying every minute with following format :
2017-06-16 00:00:22 - Meter_1_L12_15_3_0 state updated to 124.035
2017-06-16 00:01:54 - Meter_1_L12_15_3_0 state updated to 124.041
2017-06-16 00:02:22 - Meter_1_L12_15_3_0 state updated to 124.047
2017-06-16 00:04:09 - Meter_1_L12_15_3_0 state updated to 124.053
I want to extract log data exactly after one hour with the help of shell scripting of format like :
2017-06-16 00:00:22 - Meter_1_L12_15_3_0 state updated to 124.035
2017-06-16 00:59:51 - Meter_1_L12_15_3_0 state updated to 124.391
2017-06-16 01:00:22 - Meter_1_L12_15_3_0 state updated to 124.396
2017-06-16 01:58:22 - Meter_1_L12_15_3_0 state updated to 124.718
Please help me to achieve this task.Thanks
EDIT:
Reevanshi commented the following explanation:
I want to extract every first and last entry of every hour like if any hour for example 2:00 am to 3:00 am ,there are 100 entries in between of them then i just want only first and last entry between that timestamp.
Your input and output data don't correspond to each other, but basically, I think you want to output the previous line and the current line whenever the hour changes.
So, if I make the Input Field Separator either of "space" or colon, I can pick up the hour in field 2 (
$2), which gives this: