December 21st, 2007

circuit

Apparently there's a bug in sort ... or something.

So, a strange Unix thing I noticed today.

Given the following file :

> cat list2
1
1
2
A
B


Now try sorting it. First with just "-u" (sort uniquely) :

> sort -u list2
1
2
A
B


Now add "-n" to sort numerically (if the field looks like a number) :

> sort -un list2
A
1
2


Where did the "B" go ??
I've seen this in sort under Solaris 8, the GNU version in Ubuntu 7.04 and the gnuwin32 version on Windows. Surely it's a bug ?
  • Current Mood
    geeky geeky