My logs are in this format:
[2018-01-22T13:40:22,825][WARN ] message
[2018-01-22T13:41:52,830][ERROR ] message
[2018-01-22T13:45:27,831][WARN ] message
I need to write a script that will check to see if there have been any errors in the last 5 minutes. From what I've found online, something like this should work:
awk -v d1="$(date --date="-5 min" "+%Y-%m-%dT%H:%M:%S")" -v d2="$(date "+%Y-%m-%dT%H:%M:%S")" '$0 > d1 && $0 < d2 || $0 ~ d2' log.txt
But it doesn't. I think that the [ is getting in the way maybe? What else can I try?