mardi 15 juin 2021

awk remove all duplicates , but have problems with delete column with "-"

i have this input file.. I need to remove the duplicated rows in column 13 but I have a problem with the data that contains a "-" why does it not remove them

input

0|0|NULL|NULL|NULL|NULL|NULL|NULL|NULL|RS|201908|RS|129220198
0|0|NULL|NULL|NULL|NULL|NULL|NULL|NULL|RB|201908|RB|162230484
0|0|NULL|NULL|NULL|NULL|NULL|NULL|NULL|RB|201908|RB|192863252
0|0|NULL|NULL|NULL|NULL|NULL|NULL|NULL|RX|201907|RB|192863252
13220610|4|615906412|5|05502216092 |411|8|798|798|RB|201811|RB|13220610-4     
13219722|9|644118078|5|05502217789 |310|8|730|730|RS|201811|RS|13219722-9     
13219789|K|36062376|5|05202316950 |315|4|493|493|RS|201811|RS|13219789-K
13220015|7|70321801|5|05502623275 |310|1|359|359|RB|201811|RB|13220015-7 
0|0|NULL|NULL|NULL|NULL|NULL|NULL|NULL|RX|201908|RX|48510787
0|0|NULL|NULL|NULL|NULL|NULL|NULL|NULL|RS|201908|RS|129220198
13220610|4|615906412|5|05502216092 |411|8|798|798|RB|201811|RB|13220610-4
0|0|NULL|NULL|NULL|NULL|NULL|NULL|NULL|RB|201908|RB|138290077
0|0|NULL|NULL|NULL|NULL|NULL|NULL|NULL|RB|201908|RB|15568996K
13219789|K|36062376|5|05202316950 |310|4|493|493|RS|201811|RS|13219789-K

I need to remove the columns that have repeated column 13, but my code only removes the data from column 13 that does not have "-"

{seen[$13]++; a[++count]=$0; key[count]=$13} END {for (i=1;i<=count;i++) if (seen[key[i]] == 1){print a[i] >>  (NOM_ARCH".OKA")}else{
print a[i] >>   (NOM_ARCH".NOOKA")} }

desired output

0|0|NULL|NULL|NULL|NULL|NULL|NULL|NULL|RS|201908|RS|129220198
0|0|NULL|NULL|NULL|NULL|NULL|NULL|NULL|RB|201908|RB|162230484 
13219722|9|644118078|5|05502217789 |310|8|730|730|RS|201811|RS|13219722-9     
13220015|7|70321801|5|05502623275 |310|1|359|359|RB|201811|RB|13220015-7 
0|0|NULL|NULL|NULL|NULL|NULL|NULL|NULL|RX|201908|RX|48510787
0|0|NULL|NULL|NULL|NULL|NULL|NULL|NULL|RS|201908|RS|129220198
0|0|NULL|NULL|NULL|NULL|NULL|NULL|NULL|RB|201908|RB|138290077
0|0|NULL|NULL|NULL|NULL|NULL|NULL|NULL|RB|201908|RB|15568996K

appreciate your help

Aucun commentaire:

Enregistrer un commentaire