Simplified file conversion

Hi All,

I have a file like below

Topic:price   PartitionCount:5       ReplicationFactor:3     Configs:
        Topic: price  Partition: 0    Leader: 13      Replicas: 13,15,11      Isr: 11,13
        Topic: price  Partition: 1    Leader: 14      Replicas: 14,11,12      Isr: 11,12,14
        Topic: price  Partition: 2    Leader: 12      Replicas: 15,12,13      Isr: 12,13
        Topic: price  Partition: 3    Leader: 11      Replicas: 11,13,14      Isr: 11,14,13
        Topic: price  Partition: 4    Leader: 12      Replicas: 12,14,15      Isr: 12,14

I would like to convert this file into below

Topic, Partition, Replica Count, ISR Count(In-sync Replica Count) 

ln-short the o/p file should look like below

Price, 0, 3, 2
price, 1, 3, 3
price, 2, 3, 2
price, 3, 3, 3
price, 4, 3, 2

Can anyone help me out?

awk 'NR > 1 {print $3, $5, gsub(",", _, $9)+1, gsub(",", _, $11)+1}' FS="[ :\t]+" OFS=", " infile

thanks but i don't think it's printing in right order.
it's printing like this

0       Leader, 13,15,11        Isr, 1, 1
1       Leader, 14,11,12        Isr, 1, 1
2       Leader, 15,12,13        Isr, 1, 1
3       Leader, 11,13,14        Isr, 1, 1
4       Leader, 12,14,15        Isr, 1, 1

See update.

1 Like

me bad....sorry.