# Basic syntax:
if [[ "${array[*]}" =~ "${value}" ]]; then
echo "$value is in array"
fi
# Note, relative to e.g. Python, this syntax feels a little backwards. It
# checks if the value variable is in the array, which reads right to left.
# Note, if you want to check whether the element is not in the array, use:
if [[ ! "${array[*]}" =~ "${value}" ]]; then
echo "$value is not in array"
fi
array=(staging prod)
if [[ ${array[*]} =~ $1 ]]; then
echo "Supported Environment";
else
echo "Unsupported Environment";
fi
if [[ " ${array[*]} " =~ " ${value} " ]]; then
# whatever you want to do when array contains value
fi
if [[ ! " ${array[*]} " =~ " ${value} " ]]; then
# whatever you want to do when array doesn't contain value
fi