linux - Is there a way to 'uniq' by column? -
i have .csv file this:
stack2@example.com,2009-11-27 01:05:47.893000000,example.net,127.0.0.1 overflow@example.com,2009-11-27 00:58:29.793000000,example.net,255.255.255.0 overflow@example.com,2009-11-27 00:58:29.646465785,example.net,256.255.255.0 ...
i have remove duplicate e-mails (the entire line) file (i.e. 1 of lines containing overflow@example.com
in above example). how use uniq
on field 1 (separated commas)? according man
, uniq
doesn't have options columns.
i tried sort | uniq
doesn't work.
sort -u -t, -k1,1 file
-u
unique-t,
comma delimiter-k1,1
key field 1
test result:
overflow@domain2.com,2009-11-27 00:58:29.793000000,xx3.net,255.255.255.0 stack2@domain.com,2009-11-27 01:05:47.893000000,xx2.net,127.0.0.1
Comments
Post a Comment