I have the following simple script. However, it incorrectly gives the counter result to be 0.
#!/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 >= s_time && $1 <= e_time) counter++}
END{print counter}' $f_name
The data file has the format: $Date $val
The
awkcommand is in single quotes so$S_DATEand$E_DATEare being taken literally. You have a few options:Or, my favorite: