I am trying to write a script in bash that check the validity of a user input. I want to match the input (say variable x) to a list of valid values.
x
how about
echo $list | grep -w -q $x
you could either check the output or $? of above line to make the decision.
$?
grep -w checks on whole word patterns. Adding -q prevents echoing the list.
grep -w
-q