Grep date with regex

greplog-filesregexunix

I have files with lines in the following formats:

.
.
.
12/16/09 17:56:30.211 rest of line...
.
.
.
12/17/09 05:34:10.809 rest of line...
.
.

How do I grep the lines out of this file that are between two dates, i.e. all the values for one day? I need to create a daily file with the contents from all the different server logs for that day.

Best Answer

Brackets can be used to give you a range of numbers. The carrot can match the start of a line. So..

grep "^12\/1[6-8]\/09" will give you everything that starts with 12/16/09, 12/17/09, and 12/18/09

Related Topic