I want to get an interval of one hour in my log file. Here's a sample log:
2016-03-30|00:54:46,060|[WARNING]
2016-03-30|00:55:46,318|[OK]
2016-03-30|00:55:46,318|[OK]
2016-03-30|01:42:13,691|[UNKNOWN]
2016-03-30|01:53:16,356|[CRITICAL]
2016-03-30|02:56:41,410|[WARNING]
2016-03-30|02:42:13,691|[UNKNOWN]
2016-03-30|02:53:16,356|[UNKNOWN]
2016-03-30|03:56:41,410|[WARNING]
I define some variables: date_now=date +"%Y-%m-%d %H:%M:%S,%3N"
, date_minus_one=date -d "-1 hour" +"%Y-%m-%d %H:%M:%S,%3N"
and date_minus_two=date -d "-2 hour" +"%Y-%m-%d %H:%M:%S,%3N"
. I know the logic that you can get a per hour by making `date_now >= date_minus_one and date_now <= date_minus_two. But I don't know how can I make that in awk, sed or grep.
I want the output result will be:
2016-03-30|02:56:41,410|[WARNING]
2016-03-30|02:42:13,691|[UNKNOWN]
2016-03-30|02:53:16,356|[UNKNOWN]
So on and so forth to get a 1 hour interval of logs.