2012-07-10 78 views
0

要獲得我們的Solaris 10服務器上安裝的軟件版本的列表,我可以使用命令pkginfo -l。然而,它返回不同行的屬性,就像這樣:pkginfo命令的格式化輸出

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

這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]) }