[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
sort -nu: bug or feature?
From: |
Andrew Noymer |
Subject: |
sort -nu: bug or feature? |
Date: |
Tue, 7 Sep 2004 11:59:29 -0700 (PDT) |
sort -nu seems to compare only the first key, which is not what a lot of
people expect. I don't know if this is a bug, though.
THE DATA:
$ cat fish
1010 0
1010 1
1010 0
THIS works as we expect:
$ sort fish | uniq
1010 0
1010 1
SO does this:
$ sort -u fish
1010 0
1010 1
BUT I'm not really sure why making a numerical sort should bollox
everything up:
$ sort -nu fish
1010 0
FWIW this does work:
$ sort -nu -k2 fish
1010 0
1010 1
BUT even this does not work:
$ sort -nu -k2,1 fish
1010 0
Bug? Feature?
I see what's going on --- it's stopping comparison at the first key.
But I think most folks expect that "sort -nu" == "sort -n | uniq"
If this equality was never the intention, then "no problemo" as far as I
am concerned. But it seems to me that most folks assume the above
equality is in effect. On the one hand, a one-sentence clarification
could be added to the man page? On the other hand, if it's a bug, it
could be fixed.
Thanks!
Andrew