I have a variable $FOO with values one two three
.
echo $FOO
one two three
Is there a way in bash to check if two
exists and exactly matches one of the values of $FOO
I can do this
if [[ "two" =~ ^(one|two|three)$ ]]; then
echo "two is in the list"
else
echo "two is not in the list"
fi
And it works, but I'd like to check using the actual variable $FOO and not (one|two|three)$
Is this possible?