[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Weird behaviour (possibly bug) of sort
From: |
Kilian Hekhuis |
Subject: |
Weird behaviour (possibly bug) of sort |
Date: |
Tue, 16 Mar 2010 11:29:16 +0100 (MET) |
User-agent: |
SquirrelMail/1.5.1 [CVS] |
Dear coreutils maintainers,
I have found very weird behaviour in GNU sort on Linux (coreutils 7.4),
and I'm wondering if it's me doing something wrong, or whether there's a
bug in there.
I have this input file:
20 6 1234XX
12 10 1234XX
14 13 1234AA
I would like to sort on the third column first, then on the second column,
but numerical, not ASCII. I figured this should do it:
sort -k3,3 -k2,2n inp.txt
However, the result comes out wrong:
14 13 1234AA
12 10 1234XX
20 6 1234XX
Although the third column is sorted the way I want, the second isn't: 6
should come before 10. So I tried something slightly different:
sort -n -k3,3f -k2,2 inp.txt
But no such luck: though the 'f' triggers ASCII sorting, it also somehow
prevents the second -k receiving the global -n. Then I tried to switch the
columns in the input file:
20 1234XX 6
12 1234XX 10
14 1234AA 13
And what do you know? Both "-k2,2 -k3,3n" and "-n -k2,2f -k3,3" produce
the right, expected output:
14 1234AA 13
20 1234XX 6
12 1234XX 10
I'm a bit lost here, as this is behaviour that is certainly not
documented, and I would think this is a bug.
Best regards,
Kilian Hekhuis
- Weird behaviour (possibly bug) of sort,
Kilian Hekhuis <=