[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Weird behaviour (possibly bug) of sort
From: |
Pádraig Brady |
Subject: |
Re: Weird behaviour (possibly bug) of sort |
Date: |
Tue, 16 Mar 2010 13:05:07 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 |
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.