I know this was asked multiple times with respect to validating multiple variables. This however is a if condition to validate for single letters(alphabets).
I have a statement that goes like this. The arguments are passed from another script
action=$1
name=$2
gname=$3
echo "action is $action name is $name and gname is $gname" # making sure i got the args passed right
#if [ $action != B ] || [ $action != T ] || [ $action != R ] ; // This WORKS!!
if [ $action != [ B | R | T ]; then // Returns an error
echo "NADA"
exit
fi
if [ $name != SNAP1 ] || [ $name != SNAP2 ] || [ $name != SNAP3 ] ;
echo "NADA"
exit
fi
I'd like to know how to compare more than just those 3 letters and 3 variables. What if i want to validate more than say 8 letters, is there a better way to write the if statement, how can i shorten the comparison?