Created
April 3, 2019 03:16
-
-
Save alanljj/1433da4a373191051fe6c44d7d3c78b5 to your computer and use it in GitHub Desktop.
get linux version shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
Get_Dist_Name() | |
{ | |
if grep -Eqii "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then | |
DISTRO='CentOS' | |
PM='yum' | |
elif grep -Eqi "Red Hat Enterprise Linux Server" /etc/issue || grep -Eq "Red Hat Enterprise Linux Server" /etc/*-release; then | |
DISTRO='RHEL' | |
PM='yum' | |
elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then | |
DISTRO='Aliyun' | |
PM='yum' | |
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then | |
DISTRO='Fedora' | |
PM='yum' | |
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then | |
DISTRO='Debian' | |
PM='apt' | |
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then | |
DISTRO='Ubuntu' | |
PM='apt' | |
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then | |
DISTRO='Raspbian' | |
PM='apt' | |
else | |
DISTRO='unknow' | |
fi | |
echo $DISTRO; | |
} | |
if Get_Dist_Name = "Raspbian"; then | |
echo "-------- This is $DISTRO OS !!! --------" | |
else | |
echo "!!!!!!!! Never heard about this OS !!! !!!!!!!! --------" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment