What is wrong with this code?
if (( `date +%U` % 2 -eq 0 ))
then
VOLUME= "A"
else
VOLUME="B"
fi
I´m getting "syntax error in expression (error token is "0 ")" eror.
You need to use command substitution using $(...)
syntax.
You can use this command:
(( $(date +%U) % 2 == 0 )) && VOLUME="A" || VOLUME="B"
Your problem is the use of -eq
operator in the context of an arithmetic test (the double parenthesis).
You need Command Substitution $(…)
:
if (( $(date +%U) % 2 == 0 )); then VOLUME= "A" else VOLUME="B"; fi
N.B.: Why is $(…)
preferred over `…`
(backticks)?
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