Shell判断字符串包含关系

result=$(echo $strA | grep "${strB}")
if [[ "$result" != "" ]]
then
    echo "包含"
else
    echo "不包含"
fi
strA="helloworld"
strB="low"
if [[ $strA =~ $strB ]]
then
    echo "包含"
else
    echo "不包含"
fi
发布了108 篇原创文章 · 获赞 0 · 访问量 2914

猜你喜欢

转载自blog.csdn.net/VIP099/article/details/104802756