shell 判断操作系统类型

参考博客:https://blog.csdn.net/wwq921220/article/details/123240140

#!/bin/bash

uNames=`uname -s`
osName=${uNames: 0: 4}
if [ "$osName" == "Darw" ] # Darwin
then
    echo "Mac OS X"
elif [ "$osName" == "Linu" ] # Linux
then
    echo "GNU/Linux"
elif [ "$osName" == "MING" ] # MINGW, windows, git-bash
then 
    echo "Windows, git-bash" 
else
    echo "unknown os"
fi


文章目录