查看Linux系统版本
# getOSType.sh
#!/bin/bash #Author: ... #CreateDate: 2014-08-26 #Environment: Linux + Bash function Successful() { [ $? -eq 0 ] && return 0 return 1 } function GetOSName() { local l_OSName="unknown" local l_ReleaseInfo l_ReleaseInfo=$(cat /etc/redhat-release 2>/dev/null) if ! Successful; then echo ${l_OSName} return 1; fi echo ${l_ReleaseInfo} |grep -i "Red Hat Linux" >/dev/null 2>&1 if Successful; then l_OSName=‘redhat‘ fi echo ${l_ReleaseInfo} |grep -i "CentOS" >/dev/null 2>&1 if Successful; then l_OSName=‘centos‘ fi l_Version=$(echo ${l_ReleaseInfo}|sed -e "s#^.*[ ]\([0-9.]\{1,\}\)[ ].*#\1#g") if [ "${l_Version}" == "${l_ReleaseInfo}" ]; then l_Version=‘‘ fi l_Arch=‘32‘ uname -p 2>/dev/null |grep -i ‘x86_64‘ > /dev/null 2>&1 if Successful; then l_Arch="64" fi echo ${l_OSName}${l_Version}_${l_Arch} } GetOSName
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。