关于 =~ 符号解析

用一个shell例子说明=~符号的使用:

先定义一个数组

PLATSS=('center' 'trad')

if [[ "${PLATSS[@]}" =~ ${PLAT} ]];then     #

  do something

else

  do something
fi

解析: '=~' 格式表示左边输出数组值包括右边的值,左右顺序不能调换

原文地址:https://www.cnblogs.com/fjping0606/p/4418093.html