Code:
$
$
$ cat f12
hostA,invver,1.02,20100430
hostA,date,08/30/2010,06:18
hostA,use,"Unknown Server Use"
hostA,os,"5.2.0.0","5200-10-04-0750","IBM,7029-6C3","0004DBAC4C00"
hostA,obp,Sat Aug 28 20:34:22 2010
hostA,mem,2048 MB
hostA,platform,IBM,7029-6C3
hostA,serial,"104DBAC"
hostA,hostid,"0xcfc0213b"
hostB,invver,1.05,20100526
hostB,date,08/30/2010,06:18
hostB,use,"unknown-server"
hostB,os,"5.10","142900-12","sun4u","SUNW,SPARC-Enterprise"
hostB,obp,"4.24.11"
hostB,mem,65536
hostB,platform,"Sun Microsystems sun4u Sun SPARC Enterprise M5000 Server"
hostB,serial,"BEF0949C7D"
hostB,hostid,"854574e2"
hostC,platform,"Solaris Server"
hostC,serial,"XXX9999Y9Z"
hostC,hostid,"123456x7"
hostD,platform,"sun microsystems server"
hostD,serial,"YYY8888Y8Z"
hostD,hostid,"555555x5"
$
$ # I've made the assumption that "platform", "serial" and "hostid" occur in that order (in different lines) for Sun servers in your file.
$ # They do not have to be on consecutive lines for this script to work.
$
$ awk -F, '/platform.*[Ss]un/{print $1":", $3; x=1}; /serial/ && x==1{print $0}; /hostid/ && x==1{print $0; x=0}' f12
hostB: "Sun Microsystems sun4u Sun SPARC Enterprise M5000 Server"
hostB,serial,"BEF0949C7D"
hostB,hostid,"854574e2"
hostD: "sun microsystems server"
hostD,serial,"YYY8888Y8Z"
hostD,hostid,"555555x5"
$
$