Bash: if then match on multiple conditions if all are true -
i'm writing script checks 3 different variables , matches on true. need return true if conditions match. right returning true if 1 or 2 conditions match list of operators.
if [ -z "$var3" ] || [ "$var1" -ge 10 ] || [ "$var2" != "working" ]; echo "app failed "$var1" check-ins" exit 2 elif [ -n "$var3" ] || [ "$var1" -le 10 ] || [ "$var2" == "working" ]; echo "$var3" pid active connection "$var2" exit 0 fi
should replace || && ??
yes, || represents or logical operator, returns true if @ least 1 of operators true. && represents , logical operator, returns true if , if o operators true
if [ -z "$var3" ] && [ "$var1" -ge 10 ] && [ "$var2" != "working" ]; echo "app failed "$var1" check-ins" exit 2 elif [ -n "$var3" ] && [ "$var1" -le 10 ] && [ "$var2" == "working" ]; echo "$var3" pid active connection "$var2" exit 0 fi