I have got a dataset like this
tack2@domain.com,2009-11-27
overflow@domain2.com,2009-11-27
overflow@domain2.com,2009-11-27
When I am running command to delete all of the same entries of column2
sort -t ',' -k2 stars.txt -u
It is deleting the entry of column1.
In order to delete the duplicate entries of column2, I am having to enter -k3
flag
sort -t ',' -k3 stars.txt -u
Can anyone explain to me why it is happening? Why I have to enter +1 to the column in the file to delete the column?
sort -t, -k2,2 -u
. -k2 is using the text starting at the second field as the sort key, while-k2,2
makes the second field alone the sort key. What version of sort it is. It suppose it's GNU sort since it accepts options after arguments, sosort --version
should tell you. What doescat -vte
on the file gives you?man sort
, look forKEYDEF
.-k3
says that sorting key starts at column 3 (and spans to end of line),-k3,3
says that sorting key starts and ends at column 3.