The -n and -u sort options combine in a way I hadn't expected.

Given the input:

 1234,1,2,3
 1234,5,2,3

sort -n -u returns only:

 1234,1,2,3

When I had expected it to return both lines.

The man page says:


-u     For  the  default  case or the -m option, only output the
       first of a sequence of lines that compare equal.  For the
       -c option, check that no pair of consecutive lines compares
       equal.

leading me to believe that while it would sort on a numeric
key, the utility would still do the uniqueness test on the
entire line.


Reply via email to