Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How to get range time using awk command?

I have two variables $from and $to with format (hh:mm:ss)

I want to get the range time between two variables.

For example: get all range time between:

$from: 20:04:36 $to: 23:40:40

I have log txt.log:

at="20:04:35"  
at="20:04:36"  
at="20:05:31"  
........  
at="23:40:40"  
at="23:40:41"  

I want pass variable in to awk, and using:

START_TIME="20:04:35"  
END_TIME="23:40:41"  
awk -v "START=$START_TIME" - v "END=$END_TIME" -v "CURR=20:05:31" '{ if ( $CURR > "'"START"'" && $CUR < "'"END"'" ) print $0 }' txt.log  

But it is not working

share|improve this question
2  
serverfault.com/a/296560/59925 –  quanta Mar 15 '13 at 9:28
    
By now you probably know this already, but you have a typo on you $CUR variable. It should be $CURR. –  Qben Jul 4 '13 at 13:29
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.