I have a log file. Each line is prepended with a date and the date format is as below:
2016-02-01 11:34:48,567.......
How do I grep
this file for last 24 hours?
I tried few things such as below for specific time but this approach wont work for last X hours:
grep "2016-02-01 15:0[1-9]:00 logfile
Also, the following does work for -1hour but fails for -23 or -24hours:
grep "^$(date -d -23hour +'%Y-%m-%d %H')" logfile