I'm trying to get specific dates and times to get three different outcomes from the code below. Sometimes doesn't work correctly so it has been done probably incorrectly.
#!/bin/bash
currentdate=6
currenttime=17
if [[ ${currentdate#0} -ge 5 ]] && [[ ${currenttime#0} -ge 18 ]] && [[ ${currentdate#0} -le 7 ]] && [[ ${currenttime#0} -le 22 ]]
then
echo "command for Friday after 18pm until Sunday 22pm"
elif [[ ${currentdate#0} -eq 3 ]] && [[ ${currenttime#0} -ge 18 ]] && [[ ${currenttime#0} -le 20 ]]
then
echo "command for Wednesday after 18pm until 20pm"
else
echo "command for all other dates and times"
fi
There was a logic error on my function. Worked by changing it to:
if [[ ${currentdate#0} -ge 5 ]] && [[ ${currenttime#0} -ge 18 ]] || [[ ${currentdate#0} -eq 6 ]] || [[ ${currentdate#0} -le 7 ]] && [[ ${currenttime#0} -le 22 ]]