determine the operating system 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

 

Guess you like

Origin www.cnblogs.com/sea-stream/p/11414037.html