s1="helloworld"
s2="ello"
result=$(echo $s1 | grep "${s2}")
if [[ "$result" != "" ]]
then
    echo "$s1 include $s2"
else
    echo "$1 not include $s2"
fi
fileName=/home/sss/data/cl
if [[ $fileName =~cl ]]
then
    echo "$fileName include cl"
else
    echo "not include"
fi
A="helloworld"
B="low"
if [[ $A == *$B* ]]
then
    echo "包含"
else
    echo "不包含"
fi
原文:https://www.cnblogs.com/cchilei/p/14142776.html