solaris - How do I parse the output of a command into columns using awk and grep -
i have output of pkginfo -l
looks below
a: aaa1 b: bbb1 c: ccc1 d: ddd1 a: aaa2 b: bbb2 c: ccc2 d: ddd2 a: aaa3 c: ccc3 d: ddd3
i want output translated columns such looks below
a b c d aaa1 bbb1 ccc1 ddd1 aaa2 bbb2 ccc2 ddd2 aaa3 ccc3 ddd3
currenlty finding names of packages individually using pkginfo
, running pkginfo -l pkgname
output , parse on display info in columns each invocation of pkginfo -l
time consuming.
is there easier way in ksh grep/awk can store teh output of pkginfo -l
file , use grep/awk on achieve intended output?
here started.
awk -f": " 'begin {c=0} nf{a[$1 fs c]=$2;b[$1];next} {c++} end {for (i=0;i<=c;i++) {for (j in b) printf "%s\t",a[j fs i];print ""}}' file aaa1 bbb1 ccc1 ddd1 aaa2 bbb2 ccc2 ddd2 aaa3 ccc3 ddd3
Comments
Post a Comment