while read M D T R; do [[ $(( $( date +"%s" ) - $( date -d "$M $D $T" +"%s" ) )) -lt 3600 ]] && (( ++C )); done; echo $C
Nice oneliner (desculpe, não resisti) que funciona mas muito feia ...
O seguinte código, no entanto, é como isso pode ser feito de uma maneira elegante:
#!/bin/bash
#read the current date/time in unixtime format
NOW=$( date +"%s" )
while read MONTH DAY TIME REST
do
#change the read date/time to unixtime
THEN=$( date -d "$MONTH $DAY $TIME" +"%s" )
#if the difference is less than 1 hour (=3600 seconds), increase the count
(( ( NOW - THEN ) < 3600 )) && (( ++COUNT ))
done <"/home/liamcomfort/my.log"
echo "$COUNT"