lundi 13 avril 2020

How to make if conditions from array in bash [duplicate]

I have an if condition like this;

if [ "$var" != "something" ] && [ "$var" != "something2" ] && [ "$var" != "something3" ] && [ "$var" != "something4" ]; then
    # do something
fi

Which checks if $var not equals to any of the given parameters then act accordingly. However, this list is actually a lot bigger than the given example so is there a way to list them somewhere and check from that list instead of adding them individually? Similar questions to mine I found online was mostly numbers but my array list will consist of strings so I had to ask this question.

Aucun commentaire:

Enregistrer un commentaire