lundi 24 mai 2021

BASH Best way to do multiple OR statements in a IF command

I have an OR condition in a IF statement, what is the best way to do the following as I feel like its probably not best practice:

if [[ $name == "Mark" || $name == "Peter" || $name == "Alex" || $name == "Ben" || $name == "TerryCruise" ]]
code...
fi

Something equivalent to pythons "in" condition would be nice. If there is a way to create an array variable and just check if the names are in that, that'd be even better so that if in the future the names changed, the variable could just be changed instead of the if statement itself.

Any help would be appreciated. Thanks

Aucun commentaire:

Enregistrer un commentaire