How To Remove Duplicate Based on the Value?

Hi ,

Some time i got duplicated value in my files ,

bundle_identifier= B
Sometext=ABC
bundle_identifier= A
bundle_unit=500
Sometext123=ABCD
bundle_unit=400

i need to check if there is a duplicated values or not if yes , i need to check if the value is A or B when Bundle_Identified , and when Bundle_unit remove the seconde one

the Result

Sometext=ABC
bundle_identifier= A
bundle_unit=500
Sometext123=ABCD

Hi OTNA,

awk -F"=" '{gsub(" ","",$2);
if ($1=="bundle_identifier") {
if ($2=="A"){print $0;next} else {next}}
if(!a[$1]++){print}}' OFS="=" filename
1 Like

Thanks pravin27 ,

its working