Code:
awk -F: '
BEGIN {HD="Policy Name,Policy Type,Active,Effective date,Mult. Data Streams,Client Encrypt,Checkpoint,"\
"Policy Priority,Max Jobs/Policy,Disaster Recovery,Collect BMR info,Residence,Volume Pool,"\
"Server Group,Keyword,Data Classification,Residence is Storage Lifecycle Policy,"\
"Application Discovery,Discovery Lifetime,ASC Application and attributes"
print HD
HDCnt=split(HD,HDArr,",")
NXTREC=HDArr[1]
HDCM=","HD","
}
{sub (/^[\t ]*/, "", $1)
}
$1 == NXTREC && PR {for (i=1; i<=HDCnt; i++) printf "%s,", RES[HDArr[i]]
printf "\n"
delete RES
}
$1 == NXTREC {PR=1}
HDCM ~ "," $1 "," {RES[$1]=$0; sub ($1 "[^:]*:[\t ]*", "", RES[$1]); sub (/[\t ]*$/, "", RES[$1])}
END {for (i=1; i<=HDCnt; i++) printf "%s,", RES[HDArr[i]]
printf "\n"
}
' OFS=":" file
Policy Name,Policy Type,Active,Effective date,Mult. Data Streams,Client Encrypt,Checkpoint,Policy Priority,Max Jobs/Policy,Disaster Recovery,Collect BMR info,Residence,Volume Pool,Server Group,Keyword,Data Classification,Residence is Storage Lifecycle Policy,Application Discovery,Discovery Lifetime,ASC Application and attributes
Backup_bkp,Catalog_bkp,yes,08/07/2013 02:02:12,no,no,no,0,1,0,no,xyz,Backup,*ANY*,(none specified),-,no,no,0 seconds,(none defined),
002,MS-Windows,yes,07/15/2013 22:26:40,no,no,yes,0,Unlimited,0,no,dfg,NetBackup,*ANY*,(none specified),-,no,no,0 seconds,(none defined),