#!/bin/bash if [ "$1" == "" ]; then echo "No file given!" exit 1 fi for (( i = 4; i >= 0; i-- )) ; do # In %_d the underscore is important since it demands `date` # to pad with spaces (like syslog for e.g. "Jan 1" to "Jan 9") # instead of zeros. dstring=`LANG=C date -d "-$i min" +"%b %_d %R"` #echo "Entries for '$dstring':" grep "^$dstring:.. " $1 done