Is there a way to test whether an array contains a specified element?
e.g., something like:
array=(one two three) if [ \"one\" in ${array} ]; then ... f
in_array() { local needle=$1 el shift for el in "$@"; do if [ "$el" = "$needle" ]; then return 0 fi done return 1 } if in_array 1 1 2 3; then echo true else echo false fi # alternatively a=(1 2 3) if in_array 1 "${a[@]}"; then ...