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
I like using grep for this:
if echo ${array[@]} | grep -qw one; then # "one" is in the array ... fi
(Note that both -q and -w are non-standard options to grep: -w tells it to work on whole words only, and -q ("quiet") suppresses all output.)
-q
-w