var="$(command1 -l '$var2' -c 'command2|grep -c "search"')"
if [[ var !=0 ]]; then
fi
Why am I getting "conditional binary operator expected". I searched already and. I. see that [[]] is a test statement but why would it not work?
var="$(command1 -l '$var2' -c 'command2|grep -c "search"')"
if [[ var !=0 ]]; then
fi
Why am I getting "conditional binary operator expected". I searched already and. I. see that [[]] is a test statement but why would it not work?
$ in front of var when you call it, like you wrote it, it will be literally var.[[ ... ]] or (( ... )) together with variables you cannot control. In your case, it might be better to use [ "$var" -ne 0 ].!= and 0 (this is the source of the error!)!= is a string comparison operator, while it might work in your example, you want to use -ne to compare integers.Make use of shellcheck.