I am trying to extract time range from a logfile by passing shell variables in awk. This is how my log file is. 2014-11-24 12:58:59.290 1.1.1.1  etc..2014-11-24 13:58:59.290 2.2.2.2  etc..2014-11-24 14:58:59.290 3.3.3.3  etc ..2014-11-24 12:58:59.290 4.4.4.4  etc.. 2014-11-24 15:58:59.290 4.4.4.4  etc..Suppose I want to extract time range between 12 hours and 13 hours.   Here is the bash script I have written.stime=12etime=13date_=2014-11-24awk 'BEGIN {          a='$stime';b='$etime';d='$date_'; FS=[: ]       }      {   if ( $1 == d && $2 >= a && $2 < b )      print $1 $2 $3      }'  logfile.txtMy output should look like this. 2014-11-24 12:58:59.290 1.1.1.1  etc..   2014-11-24 12:58:59.290 4.4.4.4  etc..  I don't see any output nor any errors.I don't know what's is going wrong. Any help with this would be appreciated. Thank you
extract time range from log file using AWK
bash;awk
stime=12etime=13date=2014-11-24awk -v a=$stime -v b=$etime -v d=$date -F [: ]+ '  {   if ( $1 == d && $2+0 >= a && $2+0 < b )      print $1,$2,$3  }'  logfile.txtThis produces the output:2014-11-24 12 582014-11-24 12 58Notes:FS=[: ]; causes the field separator to be set to a colon or space followed by a semicolon.  That combination never occurs in the input file.In the original code, the assignment   d='$date_'; resulted in d having the value of 1979.  That is because, when introduced in awk code, the expression 2014-11-24 is interpreted as a numerical expression requiring subtraction.It is good practice  to transfer shell variables to awk using the -v option.  Both the shell and awk can require proper quoting and the -v option allows us to deal with these quoting issues one at a time.awk is capable of doing either numeric or alphabetic comparison depending on context.  By adding +0 in the code, we assure that awk is doing numeric comparison.