shell中判断字符串是否包含某串

shell中判断字符串是否包含某串

shell cmd 备注
bash if [[ "aa bb cc" =~ "bb" ]] ; then echo "in";fi 可以
bash if [ "aa bb cc" =~ "bb" ] ; then echo "in";fi 语句非法
bash if [[ "aa bb cc" = *bb* ]] ; then echo "in";fi 可以
bash if [[ "aa bb cc" == *bb* ]] ; then echo "in";fi 可以
bash if [[ "aa bb cc" == "*bb*" ]] ; then echo "in";fi 不可以
bash if [ "aa bb cc" = *bb* ] ; then echo "in";fi 不可以
bash if [ "aa bb cc" = "*bb*" ] ; then echo "in";fi 不可以
bash if [[ "aa bb cc" = "*bb*" ]] ; then echo "in";fi 不可以
bash if [ "aa bb cc" == "*bb*" ] ; then echo "in";fi 不可以
bash if [[ "aa bb cc" == "*bb*" ]] ; then echo "in";fi 不可以
sh if [[ "aa bb cc" =~ "bb" ]] ; then echo "in";fi 语句非法
sh if [ "aa bb cc" =~ "bb" ] ; then echo "in";fi 语句非法
sh if [ "aa bb cc" = "*bb*" ] ; then echo "in";fi 不可以
sh if [ "aa bb cc" = *bb* ] ; then echo "in";fi 不可以
sh if [[ "aa bb cc" = "*bb*" ]] ; then echo "in";fi 语句非法
sh if [ "aa bb cc" == "*bb*" ] ; then echo "in";fi 语句非法
sh if [[ "aa bb cc" == "*bb*" ]] ; then echo "in";fi 语句非法
sh if [[ "aa bb cc" = *bb* ]] ; then echo "in";fi 语句非法
sh if [ "aa bb cc" == *bb* ] ; then echo "in";fi 语句非法
sh if [[ "aa bb cc" == *bb* ]] ; then echo "in";fi 语句非法

shell中判断字符串是否包含某串

上一篇:C语言——计算标准差公式


下一篇:cf3