Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
See also:… – MikeyB Dec 17 '09 at 21:36
up vote 2 down vote accepted

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

share|improve this answer
Thanks, I was so hung up on the timestamp that I didn't think of just using the day. – Lance Roberts Dec 17 '09 at 19:52
You could add a space after the year also, like grep "^12\/1[6-8]\/09 " to be sure. – ℝaphink Dec 17 '09 at 19:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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