小智 15
您是正确的,oslevel 将为您提供当前安装的版本,但如果支持人员向您提出问题,那么这并不总是足够的信息。
# oslevel <--- 这只会给你基础级别
更准确地说,您应该使用以下命令,该命令将为您提供额外的技术级别、维护级别和服务包级别信息。
# oslevel -s
5300-09-02-0849
Run Code Online (Sandbox Code Playgroud)
这会给你
在某些旧版本的 AIX 上,-s 选项不可用,您应该使用 -r 选项,该选项将报告技术级别
我希望这有帮助
迈克·舍勒
我刚刚将它添加到我的 ~/.profile 中,所以我在登录时立即看到了 AIX 版本:
function aixversion {
OSLEVEL=$(oslevel -s)
AIXVERSION=$(echo "scale=1; $(echo $OSLEVEL | cut -d'-' -f1)/1000" | bc)
AIXTL=$(echo $OSLEVEL | cut -d'-' -f2 | bc)
AIXSP=$(echo $OSLEVEL | cut -d'-' -f3 | bc)
echo "AIX ${AIXVERSION} - Technology Level ${AIXTL} - Service Pack ${AIXSP}"
}
aixversion
Run Code Online (Sandbox Code Playgroud)
示例输出:
AIX 7.1 - Technology Level 3 - Service Pack 1
Run Code Online (Sandbox Code Playgroud)
注意:此功能同时兼容 KSH 和 BASH,因此如果您是 BASH 迷,可以将 ~/.bashrc 放入。
nb2:oslevel 的最后 4 位数字是 SP 发布的年份和星期。我并不特别想看到那个,所以我把它省略了。我对 Version/TL/SP 很满意。
编辑 2018-02-22:我刚刚提出了一个等效但更短的实现,不再依赖bc和使用awk而不是cut& bc。
作为单线:
oslevel -s | awk -F- '{printf "AIX %.1f - Technology Level %d - Service Pack %d\n",$1/1000,$2,$3}'
Run Code Online (Sandbox Code Playgroud)
输出:
AIX 5.3 - Technology Level 9 - Service Pack 2
Run Code Online (Sandbox Code Playgroud)
作为外壳函数:
aixversion() {
oslevel -s | awk -F- '{printf "AIX %.1f - Technology Level %d - Service Pack %d\n",$1/1000,$2,$3}'
}
aixversion
Run Code Online (Sandbox Code Playgroud)
输出:
AIX 5.3 - Technology Level 9 - Service Pack 2
Run Code Online (Sandbox Code Playgroud)