I have the following bash script (test_script.sh):
#!/bin/sh
case=test
var1=90
echo "var1 = $var1"
var2=$(( var1 * 4 ))
echo "var2 = $var2"
if (( var1 > 80 ))
then
pot=filled
else
pot=empty
fi
cat > message.txt << EOF
Hellow world! The pot is $pot .
EOF
The output of this script is:
var1 = 90
var2 = 360
./test_script.sh: 10: ./test_script.sh: var1: not found
What is the cause for this "var1: not found" message ?
Thanks.
if (( $var1 > 80 ))– eblock Jun 18 '20 at 08:38sh, notbash. Inshscripts,(( ... ))is just a nested subshell, not an arithmetic evaluation at all. – Kusalananda Jun 18 '20 at 08:54bash(notsh), the(( ... ))introduces an arithmetic context. There is no need to use$on variables in arithmetic contexts inbash. – Kusalananda Jun 18 '20 at 08:56