Reputation: 833
I am trying to perform a OR operation between two sub AND conditions like as follows.
elif [[ $RBIT >= 7000.00 && $RBIT <= 15000.00 ]] || [[ $TBIT >= 7000.00 && $TBIT <= 15000.00 ]]; then
echo #statements;
exit 0;
fi
But getting it in error.
/script: line 20: syntax error in conditional expression
/script: line 20: syntax error near `7000.00'
/script: line 20: `elif [[ $RBIT >= 7000.00 && $RBIT <= 15000.00 ]] || [[ $TBIT >= 7000.00 && $TBIT <= 15000.00 ]]; then'
Of course, the variables RBIT and TBIT has float values with 2 decimal points.
I am confused if I caused a syntax error here or 'if condition' doesn't work like that way. Kindly help.
Upvotes: 2
Views: 98
Reputation: 42999
Bash supports only integer math. So, you could rewrite your condition as:
elif ((RBIT >= 7000 && RBIT <= 15000)) || ((TBIT >= 7000 && TBIT <= 15000)); then
While dealing with integers, ((...))
is a better construct to use. And $
is optional for variable expansion inside ((...))
expression.
You may want to see this related posts:
Upvotes: 2