bash shell 使用 uname 命令获取系统名称


# 获取系统名称
function xrsh_get_osname()
{
    uname -s
}
 
# 转换/统一系统名称
#参数:1 系统名称
# 例子:
#    获取并转换
#    
xrsh_cvt_osname `xrsh_get_osname`
#     如在 linux 下系统名称通常为 Linux,转换后为 linux
# 注解:不在函数内处理的系统名称,不做转换
function xrsh_cvt_osname()
{
    local _xrsh_tmp=$1

    case $_xrsh_tmp in
      Linux)        _xrsh_tmp=linux      ;;
      SunOS)        _xrsh_tmp=sun        ;;
      AIX)          _xrsh_tmp=aix        ;;
      HP-UX)        _xrsh_tmp=hpux    ;;
      Darwin)       _xrsh_tmp=osx        ;;
      FreeBSD)      _xrsh_tmp=freebsd ;;
      QNX)          _xrsh_tmp=qnx        ;;
      *)        ;;
    esac
    echo $_xrsh_tmp
}

你可能感兴趣的:(shell)