On 16/03/10 10:29, Kilian Hekhuis wrote:
> 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
The soon to be released --debug option
illustrates that the leading spaces are used
which causes an issue for you as the third column
will have varying numbers of spaces.
$ sort --debug -k3,3 -k2,2n ~/inp.txt
14 13 1234AA
___________
__
______________________
12 10 1234XX
___________
__
______________________
20 6 1234XX
____________
_
______________________
If you add the -b option you should be sorted (pardon the pun).
cheers,
Pádraig.