shell查找数组是否有特定的值
arr_host=("abc" "123" "tom")
find_value="abc"
方法1
res=$(echo "${arr_host[@]}" | grep -wq "${find_value}" && echo "yes" || echo "no")
方法2
if [[ "${arr_host[@]}" =~ "${find_value}" ]];then
echo "have"
else
echo "no"
fi