九零不老心
Published on 2018-12-22 / 46 Visits
0

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

if [[ " ${array[@]} " =~ " ${value} " ]]; then # whatever you want to do when arr contains value fi if [[ ! " ${array[@]} " =~ " ${value} " ]]; then # whatever you want to do when arr doesn't contain value fi