I need logs only from 09:36 to 09:39 in server logs where the timestamp is 2019-03-19T09:37:19 like this. Can anyone suggest me grep command for this
12 Answers
grep '2019-03-19T09:3[6-9]' /var/log/syslog Because you said your timestamp is 2019-03-19T09:37:19. I suggest you do:
- Press CTRL + ALT + T.
Run the command (
-Efor extended regex):sudo grep -E '2019-03-19T09:3[6-9]' <file or file_path>
To be direct, the above command could be (if run immediately after CTRL + ALT + T or another path):
sudo grep -E '2019-03-19T09:3[6-9]' /var/log/syslogOr (if in /log/ folder already...):
sudo grep -E '2019-03-19T09:3[6-9]' syslogI hope that's clear enough to help!