Bash If Element in Array
# 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
Charles-Alexandre Roy