How to grep by date range

Have you ever wonder how to grep a file within a date range?

[codesyntax lang="bash"]

cat file.log | sed -n '/2012-01-05 16:55/,/2012-01-05 18:30/p' > file.log.date_range

[/codesyntax]

One thought on “How to grep by date range”

  1. You’ll get unexpected output if the ending date “2012-01-05 18:30” isn’t in the file.log file.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.