判断字符串中是否包含某些字符
disk=`cat /etc/system-release`g1="CentOS Linux release 7"g2="haha"if [[ $disk =~ $g1 ]];thenehco "包含"fiif [[! $disk =~ $g1 ]];thenehco "不包含"fiif [[ ! $disk =~ $
·
disk=`cat /etc/system-release`
g1="CentOS Linux release 7"
g2="haha"
if [[ $disk =~ $g1 ]];then
ehco "包含"
fi
if [[ ! $disk =~ $g1 ]];then
ehco "不包含"
fi
if [[ ! $disk =~ $g2 ]];then
echo "不是不包含"
fi
更多推荐
已为社区贡献1条内容
所有评论(0)