shell 判断字符串是否在数组中

Posted on Posted in bash

> ARR是你的数组名,item是要查找的字符串。

  1. if echo "${ARR[@]}" | grep -w "item" &>/dev/null; then  
  2.     echo "Found"  
  3. fi  

Leave a Reply

Your email address will not be published. Required fields are marked *

five × one =