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

 

posted @ 2019-08-26 18:03  anobscureretreat  阅读(5260)  评论(3编辑  收藏  举报