要获取Solaris 10服务器上安装的软件版本列表,我可以使用命令pkginfo -l
。但是,它返回不同行的属性,如下所示:
PKGINST: bteq1310
NAME: Teradata BTEQ Utility
CATEGORY: application
ARCH: Solaris9/SPARC
VERSION: 13.10.00.04
BASEDIR: /opt
VENDOR: Teradata Corporation
PSTAMP: esssol00920110210172759
INSTDATE: Jul 01 2012 21:23
STATUS: completely installed
FILES: 10 installed pathnames
6 shared pathnames
6 directories
4 executables
1403 blocks used (approx)
是否有类似于pkginfo
的命令会在列中而不是在单独的行中返回相同的信息?我真的只对PKGINST,NAME,VERSION,INSTDATE和STATUS值感兴趣。
答案 0 :(得分:0)
这个awk脚本似乎有效:
BEGIN { FS=": "; }
/PKGINST/ { pkg = $2; p[$2] = $2; }
/NAME/ { n[pkg] = $2; }
/VERSION/ { v[pkg] = $2; }
/INSTDATE/ { i[pkg] = $2; }
/STATUS/ { s[pkg] = $2; }
END { for (m in p) printf ("%s\t%s\t%s\t%s\t%s\n", m, n[m], v[m], i[m], s[m]) }