title: How to search for lines in a file between two timestamps using Bash
body: <p>In bash I am trying to read a log file and will print only the lines that have a timestamp between two specific times. The time format is hh:mm:ss. For example, I would be searching for lines that would fall between 12:52:33 to 12:59:33.</p>
  
  <p>I want to use regular expression because I can use it in <code>grep</code> function.</p>
  
  <p>Each log line begins with <code>some_nr 2014-05-15 21:58:00,000000 rest_of_line</code>.</p>
  
  <p>My solution gives me lines with 1 min margin. I cut out <code>ss</code> and take all lines with <code>hh:mm:[0-9]{2}</code>. $2 has format <code>filename_hh:mm:;</code> for example: <code>"24249_16:05:;24249_16:05:;24249_16:07:;24249_16:07:;24249_16:08:"</code></p>
  
  <p>My code:</p>
  
  <pre><code>B=$2  
  
  for line in ${B//;/ } ;
  do  
      TENT=`echo $line | awk '{split($0,numbers,"_"); print numbers[1]}'`"_logs.txt"
      TIME=`echo $line | awk '{split($0,numbers,"_"); print numbers[2]}'`"[0-9]{2}"
  
      grep -iE ${TIME} ${TENT} &gt;&gt; ${FILE1}
  done
  </code></pre>
  
  <p>I need a solution with 15 sec margin for any time not 60. I want to have input in format <code>filename_hh:mm:ss</code> and take lines for hh:mm:ss +/- 15s or <code>filename_hh:mm:ss(1)_hh:mm:ss(2)</code> and take lines between hh:mm:ss(1) and hh:mm:ss(2). For sometime there is no lines so the solution should 'recognize' if sometimes match inputted interval or not. </p>
  
  <p>Log files look like this:</p>
  
  <pre><code>1002143 1002143 2014/15/05 22:09:52.937004 bla 
  1002130         2014/15/05 22:09:44.786002 bla bla
  1001667         2014/15/05 22:09:44.592009 bl a bla
  1001667 1001667 2014/15/05 22:09:44.592009 bl a bla
  </code></pre>