grep a date-time range
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Shell > grep a date-time range




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    grep a date-time range  
Mr_Bill


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-16-06 10:53 PM

These files have in them a date and time formated as:

03/16/06 01:16 am

Is there a way for me to grep all files that fall between
03/14/06 and 03/16/06 between 12:00 am and 01:00 am?

Thanks,
Mr_Bill








[ Post a follow-up to this message ]



    Re: grep a date-time range  
Stephane Chazelas


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-16-06 10:53 PM

On Thu, 16 Mar 2006 14:06:59 GMT, Mr_Bill wrote:
> These files have in them a date and time formated as:
>
> 03/16/06 01:16 am
>
> Is there a way for me to grep all files that fall between
> 03/14/06 and 03/16/06 between 12:00 am and 01:00 am?
[...]

grep -lE '03/1[4-6]/06 (12:[0-5][0-9]|01:00) am' -- *.txt

--
Stephane





[ Post a follow-up to this message ]



    Re: grep a date-time range  
Mr_Bill


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-16-06 10:53 PM

On Thu, 16 Mar 2006 14:25:04 +0000, Stephane Chazelas wrote:
 
> [...]
>
> grep -lE '03/1[4-6]/06 (12:[0-5][0-9]|01:00) am' -- *.txt

Thank you so much!

Let me see if I have the syntax straight.
(12:[0-5][0-9]|01:00) uses the () because we used the "|" and
the "|" is, in this case, a logical "or"?

The space between the date and time expressions represents
a logical "and"?

Would tell me, please, what the "--" in -- *.txt does?

Thanks again!
Mr_Bill





[ Post a follow-up to this message ]



    Re: grep a date-time range  
Kurt Swanson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-16-06 10:53 PM

Mr_Bill <No_thanks@null_mail.org> writes:
> On Thu, 16 Mar 2006 14:25:04 +0000, Stephane Chazelas wrote:
 
[vbcol=seagreen] 
[vbcol=seagreen]
> Thank you so much!

> Let me see if I have the syntax straight.
> (12:[0-5][0-9]|01:00) uses the () because we used the "|" and
> the "|" is, in this case, a logical "or"?

right...

> The space between the date and time expressions represents
> a logical "and"?

no, that represents a space... the OR'ing is what's in the brackets:
[4-6], for example, represents 4 or 5 or 6.

> Would tell me, please, what the "--" in -- *.txt does?

it says "anything after me is not an option, but a parameter/argument
to grep, in case one of the files starts with a '-'."
--
© 2006 Kurt Swanson AB





[ Post a follow-up to this message ]



    Re: grep a date-time range  
Mr_Bill


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-16-06 10:53 PM

On Thu, 16 Mar 2006 07:58:55 -0800, Kurt Swanson wrote:
 
>
> no, that represents a space...

grep -lE '03/1[4-6]/06 (12:[0-5][0-9]|01:00) am' -- *.txt
^
This space

But as soon as I typed that I realized this not a date AND time expression
but a single string that can have possible characters in possible places.

Thanks,
Mr "I feel strangely empowered now" Bill





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 04:12 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register