this is one way you can do it with shell and date command
#!/bin/bash
current=$(date +%R)
for file in *main*
do
d=$(date +%R -r "$file")
if [ "$d" = "$current" ];then
echo "GREEN: $file, current:$current, d: $d"
else
echo "RED: $file, current: $current, d: $d"
fi
done
note that you will have to adjust to your own needs, since you may just want to compare date only, or time only, etc.. whatever it is, check the man page of date for various date formats.
If you want to do it with awk, here's a pure awk(+GNU date) solution
awk 'BEGIN{
cmd="date +%R"
cmd|getline current
close(cmd)
for(i=1;i<=ARGC;i++){
file=ARGV[i]
if(file!=""){
cmd="date +%R -r \047"file"\047"
cmd |getline filetime
close(cmd)
if( filetime==current){
print "GREEN: "file
}else{
print "RED: "file
}
}
}
}
' *