Need to sort an output

with a command i get a long list (example) and the entrys are intended.

 
      DName=AAAAA
          DName=AAAAA
          lba=838,860,800
              label=ftw_1
      DName=BBBBB
          DName=BBBBB
          lba=838,860,800
              label=ftw_2
      DName=CCCCC
          DName=CCCCC
          lba=838,860,800
              label=ftw_3

That list is arround 1000 lines and come from an CLI request. One "Block" is from DName to "label"
I CANT supress that double "DName". What i need is

AAAAA;838,860,800;ftw_1

Since two hours i play around but i cant get it to work as i like or what i need. My sed skills are to small.

Please show next time first with what code you have tried so far.

$ awk -F\= '/DName=/ {a=$2} /lba=/ {b=$2} /label=/ {print a OFS b OFS $2}' OFS=\; infile
AAAAA;838,860,800;ftw_1
BBBBB;838,860,800;ftw_2
CCCCC;838,860,800;ftw_3

Hello Serano,

Following may help you in same.

awk '/DName/{sub(/.*=/,X,$0);A=$0;getline;if($0 ~ /DName/){getline};if($0 ~ /lba=/){sub(/.*=/,X,$0);A=A ";"$0;getline};if($0 ~ /label/){sub(/.*=/,X,$0);A=A ";" $0};print A;A=""}'  Input_file
 

Output will be as follows.

AAAAA;838,860,800;ftw_1
BBBBB;838,860,800;ftw_2
CCCCC;838,860,800;ftw_3
 

Now above code is considering that your Input_file is always having a sequence in which first string DName , then next line has string DName= , then then next line has string lba= , followed by string label= in next line.

Thanks,
R. Singh

Big Thx :b: