Hi all,
Can anyone suggest how to formulate the if/then when TIME equals a certain time, in this case 23:55:00
export TIME=`date +%T`
function tnsrec {
if $TIME = 23:55:00; then
otherfunction
else exit
fi
}
Thanks in advance.
jd
Hi all,
Can anyone suggest how to formulate the if/then when TIME equals a certain time, in this case 23:55:00
export TIME=`date +%T`
function tnsrec {
if $TIME = 23:55:00; then
otherfunction
else exit
fi
}
Thanks in advance.
jd
export TIME=`date +%T`
function tnsrec {
if [ $TIME = "23:55:00" ]
then
#otherfunction
else
exit
fi
}
Note that if you're off by one second, it won't work...
Hmm yes, good point.
How do I introduce a 'BETWEEN' condition?
ie something like
export TIME=`date +%T`
function tnsrec
{ if [ $TIME >= "23:55:00" OR $TIME < "23:55:59"]
then
#otherfunction
else exit
fi
}
Any ideas?
You could try stripping the colons and using it as an integer with -eq -gt -ge etc.
export TIME=$(date +"%H%M")
function tnsrec
{ if [ $TIME -eq 2355 ]
then #otherfunction
else exit
fi
}
Thanks for your reply.
I think I need to be able to check if TIME is between two DATEs.
that was I dont have to be sp specific about the TIME which could be a problem if you are out by 1 second or so.
So I believe I need a command to check a between condition.