0
Oct 20 13:12:01 2016 aaaaaaaaaaaaaaaaaaaaaaaaaaaa
Dec 9 16:13:01 2016 bbbbbbbbbbbbbbbbbbbbbbbbbbbb
Jan 20 11:11:01 2017 cccccccccccccccccccccccccccc

How do I grep within 2 date range. For e.g, 10/19/2016 12:24 to 01/08/2017 19:06

user7233710
  • 41
  • 1
  • 2
  • Open the file, parse each line, determine if the date matches, then optionally print the line. Please share what you've written so far so that we can know precisely which part you are struggling with. – Robᵩ Oct 25 '17 at 16:59
  • `grep` does not understand dates. All it understand is regular expressions. So, you will need to create a regular expression that matches the dates you want to filter. (Which might not be very simple thing, prehaps grep is not the right tool for this. It will be simpler to do it with some programming language or `awk`) – sid-m Oct 25 '17 at 17:01
  • Related: https://stackoverflow.com/questions/7706095/filter-log-file-entries-based-on-date-range – Robᵩ Oct 25 '17 at 17:54

1 Answers1

0

AFAIK, you cannot.

However, there is a solution with awk here: https://unix.stackexchange.com/questions/76805/read-log-file-between-two-dates

Matthieu.V
  • 160
  • 9
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/17736453) – thumbtackthief Oct 25 '17 at 18:08
  • I sort-of agree with @thumbtackthief. But your answer does answer the question in and of itself - "you cannot" is an answer. But your answer would be much better if you cut and paste the relevant bits of that other answer - marking what you copy as direct quotes, of course. A link without some summary of the relevant parts is usually a bad idea unless it's purely a reference. In your case it is too close to the core of your answer to leave the link alone. –  Oct 25 '17 at 18:22