I need to detect whether the current minutes are even or odd regardless of the time zone. I tried this according to answers from several sites:
#!/bin/bash
n=$(date +"%M")
r=`expr$n%2`
if [ r -eq 0 ]
then
echo "Even minute"
else
echo "Odd minute"
fi
When I run the script I get
./Odd_even.sh: line 5: expr04%2: command not found
./Odd_even.sh: line 6: [: r: integer expression expected –
What is wrong here?
expr
is an external command likels
and like any command you are required to use spaces to separate the command from its arguments.