也许,时间见过我们

脚本

判断子字符串包含关系: =~ 

a=`cat /proc/version`
 
b="arwin"
c="entos"
d="buntu"
 
if [[ $a =~ $b ]];then
echo "mac"
elif [[ $a =~ $c ]];then
echo "centos"
elif [[ $a =~ $d ]];then
echo "ubuntu"
else
echo $a
fi

 

posted on 2022-02-08 10:31  画入新雪  阅读(462)  评论(0编辑  收藏  举报

Copyright ©2017 画入新雪