-1

I am trying to filter a range between dates with time in a log file with the following format for the dates and time: for example~

15-09-2019 18:27:33
16-09-2019 16:45:23
17-09-2019 11:26:36

I tried using the below:

egrep "11-09-2019 23:44:01.000|16-09-2019 14:46:32.000" logfile

But it didnt work as no result come out even tho the log consist thoe data for that date and time frame. Is my syntax wrong?

Thanks in advance!

I've found the solution to my query...and that is using sed. Below is the general syntax i used..

sed -n "/$START/,/$END/p"

Thanks for the help! :)

2
  • 2
    Possible duplicate of Filter log file entries based on date range
    – SMA
    Commented Oct 13, 2019 at 13:33
  • I tried using awk -vDate=date -d '13:20' +[%d/%b/%Y:%H:%M:%S -vDate2=date -d'13:30' +[%d/%b/%Y:%H:%M:%S ' { if ($4 > Date && $4 < Date2) print $0}' access.log but it did not work. Nothing came out
    – TxRx
    Commented Oct 14, 2019 at 1:06

1 Answer 1

-1

I've found the solution to my query...and that is using sed. Below is the general syntax i used..

sed -n "/$START/,/$END/p"

Thanks for the help! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.