title: How can I pass shell variables to awk?
body: <p>I have the following simple script. However, it incorrectly gives the counter result to be 0.</p>
  
  <pre><code>#!/usr/local/bin/bash
  f_name="test.stat"
  S_Date="2012-02-10"
  E_Date="2012-02-13"
  
  awk 'BEGIN {FS="\t";s_time = mktime($S_Date);e_time = mktime($E_Date);counter=0}
       {if ($1 &gt;= s_time &amp;&amp; $1 &lt;= e_time) counter++}
       END{print counter}' $f_name
  </code></pre>
  
  <p>The data file has the format: $Date $val</p>