I want to read a variable's data and see if any of it's comma-separated data matches.
Something like:
allowed_versions={v1.0,v1.1,v1.5,v2.3}
read -r -p 'Enter a version: ' version_inputted
if [[ "${version_inputted}" == "${allowed_versions}" ]]
then
echo 'That version is allowed.'
else
echo 'That version is NOT allowed.'
fi
So, in practice, it would look like:
Enter a version: v1.0
That version is allowed.
Enter a version: v9.6
That version is NOT allowed.
Enter a version: v1.5
That version is allowed.
Enter a version: asdflj';~!@ #$%^&*)_+=-<>,.?/~`\|}{][:"(
That version is NOT allowed.
Using bash 3.2.57(1)-release on OSX El Capitan 10.11.6.
I really prefer to use a oneliner for the variable, too, if possible. Thanks.