shell 判断操作系统

#!/bin/sh

a=`uname  -a`

b="Darwin"
c="centos"
d="ubuntu"

if [[ $a =~ $b ]];then
    echo "mac"
elif [[ $a =~ $c ]];then
    echo "centos"
elif [[ $a =~ $d ]];then
    echo "ubuntu"
else
    echo $a
fi

猜你喜欢

转载自www.cnblogs.com/sea-stream/p/11414037.html
今日推荐