-2

i have large list (6 million lines) and want to sort unique by column #2, how to do it by sort command? In example

CONT,000-00-0000,GRAM
BEVE,507-66-6876,IGHT
MICH,000-00-0000,EVINS
CONT,111-11-1111,GRAM

trasnfer to

CONT,000-00-0000,GRAM
BEVE,507-66-6876,IGHT
CONT,111-11-1111,GRAM
  • 1
    Does this answer your question? [Is there a way to 'uniq' by column?](https://stackoverflow.com/questions/1915636/is-there-a-way-to-uniq-by-column) – Wiktor Stribiżew Sep 29 '21 at 10:11

1 Answers1

1
$ awk -F, '!array[$2]++' input_file
CONT,000-00-0000,GRAM
BEVE,507-66-6876,IGHT
CONT,111-11-1111,GRAM
HatLess
  • 10,622
  • 5
  • 14
  • 32