0

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

2
2

&& 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
1
  • thanks, but another error happends: ` [: too many arguments`
    – Yiling Liu
    Apr 16 '19 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.