If Statement in Bash with Multiple Conditions

Took me a little while to get this syntax because bash is super annoying with it’s syntax being different from every other reasonable programming language.

Posting this example so I never have to find it again.

VARIABLE_BOOLEAN="TRUE"

if  [[ -z $VARIABLE_BOOLEAN ]] || [[ ! -z $VARIABLE_BOOLEAN && $VARIABLE_BOOLEAN == 'TRUE' ]]; then
    echo "variable true or null"
fi

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s