mercredi 29 mars 2017

Two AND/OR in one bash if statement

i have a special condition to test in a bash script. I thougt about something like:

if [[ $categorie = "DG" || $categorie = "DI" ]] && [[ $client != "host1" || $client != "host2" ]]; then
    echo "requirements are met"
else
    echo "requirements not met"
fi

In Words: If categroie is DG OR DI AND client is NOT host1 OR host2 then do stuff.

Is this correct? For me it looks like it just cares about the categorie and if the categorie condition is met it's ok and prints "requirements are met" and don't care about the condition for the client at all.

Kind

Regards

Aucun commentaire:

Enregistrer un commentaire