code:
if [ $mintemp -ge 15 && $maxtemp -le 28 ]; then echo "nice day"; fi
I already have spaces between [ and $Mintemp , 28 and ]
but the error still happend
code:
if [ $mintemp -ge 15 && $maxtemp -le 28 ]; then echo "nice day"; fi
I already have spaces between [ and $Mintemp , 28 and ]
but the error still happend
&&
is not a []
argument (since [
is actually a program), it is Bash's operator for running second command if the first one succeeds. So for bash your script looks like:
if ([ $mintemp -ge 15) && ($maxtemp -le 28 ]; then echo "nice day"; fi)
Which is invalid. You can however do it like:
if [ $mintemp -ge 15 ] && [ $maxtemp -le 28 ]; then echo "nice day"; fi
[[ ... ]]
instead of[ ... ]
and then&&
is OK. – glenn jackman Apr 16 '19 at 15:02