#!/bin/bash
if [ `date +%u` -lt 6 && `date +%H` == '19' ] ; then
echo 'Sorry, you cannot run this program today.'
else
echo 'yes, you can run today'
fi
The script above is to run a program on weekdays and every 7PM. I have check the spaces and it still return error : date.sh: 2: [: missing ]
Change it to:
#!/bin/bash
if [ `date +%u` -lt 6 ] && [ `date +%H` == '19' ] ; then
echo 'Sorry, you cannot run this program today.'
else
echo 'yes, you can run today'
fi
Note that the [ is just a shorthand for the test command and ] the last argument to it. The && operator is used like in any other command line, for example cd /home && ls
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With