Like this with awk
:
yourcommand | awk -F: '/Name/{n=$2} /Serial/{s=$2} /Firmware/{f=$2} END{printf "%s,%s,%s\n",n,s,f}'
So, if awk
sees Name
, it saves the second field in the variable n
. If it sees Serial
, it saves the second field in variable s
. If it sees Firmware
, it saves the second field in f
. At the end it prints n,s,f.
The -F:
sets the field separator to a colon.