美文网首页
通过shell判断操作系统发行版

通过shell判断操作系统发行版

作者: 已不再更新_转移到qiita | 来源:发表于2019-07-07 09:16 被阅读0次
    if [[ "$OSTYPE" == "linux-gnu" ]]; then
        if [ -f /etc/redhat-release ]; then
            echo "Redhat Linux detected."
        elif [ -f /etc/SuSE-release ]; then
            echo "Suse Linux detected."
        elif [ -f /etc/arch-release ]; then
            echo "Arch Linux detected."
        elif [ -f /etc/mandrake-release ]; then
            echo "Mandrake Linux detected."
        elif [ -f /etc/debian_version ]; then
            echo "Ubuntu/Debian Linux detected."
        else
            echo "Unknown Linux distribution."
        fi
    elif [[ "$OSTYPE" == "darwin"* ]]; then
        echo "Mac OS (Darwin) detected."
    elif [[ "$OSTYPE" == "freebsd"* ]]; then
        echo "FreeBSD detected."
    else
        echo "Unknown operating system."
    fi
    

    https://getsubstrate.io

    相关文章

      网友评论

          本文标题:通过shell判断操作系统发行版

          本文链接:https://www.haomeiwen.com/subject/psosqctx.html