您的位置:首页 > 运维架构 > Shell

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

2012-07-18 15:13 716 查看


#获取系统名称


function xrsh_get_osname()

{

    uname -s

}
 
#转换/统一系统名称
#参数:1系统名称
#例子:
#    获取并转换
#    xrsh_cvt_osname `xrsh_get_osname`
#    如在 linux 下系统名称通常为 Linux,转换后为 linux
#注解:不在函数内处理的系统名称,不做转换
[b]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

}
[/b]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息