vendredi 3 février 2017

Bash if statement with AND operator

Trying to comparisons with a variable against strings, i tried code as per the solution from http://ift.tt/2kAulaz

if [ "$ACTION" != "dry" ] && [ "$ACTION" != "prune" ]
then
    echo "Invalid"
fi

This does not work for me, i get no error messages it's like it just skips the code block.

I have also tried like this as per answer here Bash if statement with multiple conditions

if [[ "$ACTION" != "dry" && "$ACTION" != "prune" ]]
then
    echo "Invalid"
fi

This echoes "Invalid" if $ACTION is anything other than "dry", even if its "prune"

Any suggestions?

Aucun commentaire:

Enregistrer un commentaire