1st solution: With your shown samples, please try following awk
program.
awk '
BEGIN{ OFS="," }
{
for(i=1;i<=NF;i++){
if(i==1){
sub(/:$/,"",$i)
}
value[i]=(value[i]?value[i] OFS:"")$i
}
}
END{
for(i=1;i<=NF;i++){
print value[i]
}
}
' Input_file
Explanation: Adding detailed explanation for above.
awk ' ##Starting awk program from here.
BEGIN{ OFS="," } ##Setting OFS to comma in BEGIN section.
{
for(i=1;i<=NF;i++){ ##Traversing through all fields here.
if(i==1){ ##If its first field then do following.
sub(/:$/,"",$i) ##Substitute ending colon with NULL in 1st field.
}
value[i]=(value[i]?value[i] OFS:"")$i ##Creating value with index of i and keep appending $i in it.
}
}
END{ ##Starting END block from here.
for(i=1;i<=NF;i++){ ##Traversing through all fields here.
print value[i] ##Printing value with index of i here.
}
}
' Input_file ##Mentioning Input_file name here.
2nd solution: In case your Input_file can have dynamic(not fixed) number of fields per lines then try following, which will print values till maximum number of field numbers.
awk '
BEGIN{ OFS="," }
{
for(i=1;i<=NF;i++){
if(i==1){
sub(/:$/,"",$i)
}
value[i]=(value[i]?value[i] OFS:"")$i
}
nf=(nf>NF?nf:NF)
}
END{
for(i=1;i<=nf;i++){
print value[i]
}
}
' Input_file