Hi,

I trying to test two condition together (AND) under bash but it's not working...

The goal is ti have True when two variables are either not set or empty (empty string)

I've tried

if [[ -n VARIABLE1 && -n VARIABLE2 ]]; then
    echo "OK"
fi

Here I get the "OK" no matter what .

Thanks.

you are viewing a single comment's thread
view the rest of the comments
[–] 2 points 1 year ago* (last edited 1 year ago)

The variables need a dollar sign: $VARIABLE1

help test shows what -n and -z do.

  • source
  • parent