coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does sort -2,3n work properly?


From: Pádraig Brady
Subject: Re: Does sort -2,3n work properly?
Date: Fri, 17 Jan 2014 11:26:15 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 01/17/2014 10:37 AM, Bartosz Gołaszewski wrote:
> Hi,
> 
> for the following input:
> 42      1       3       woot
> 42      1       010     zoology
> egg     1       2       papyrus
> 7       3       42      soup
> 999     3       0       algebra
> 
> this is what debug-enabled sort in coreutils 8.22 outputs:
> 
> % sort --debug ./input -k2,3n
> sort: using simple byte comparison
> sort: key 1 is numeric and spans multiple fields

So these are warning messages indicating a usage issue.
The specific one here is you've _spanned_ multiple fields
but numeric compares auto terminate at the first numbers.

> 42      1       010     zoology
>         _
> _______________________________
> 42      1       3       woot
>         _
> ____________________________
> egg     1       2       papyrus
>         _
> _______________________________
> 7       3       42      soup
>         _
> ____________________________
> 999     3       0       algebra
>         _
> _______________________________
> 
> It seems as if only the second field was used in comparison, even
> though sort knows that the key 'spans multiple fields'. Is this a
> correct behaviour? If so - could anyone explain why?

You probably want to compare multiple fields in sequence. I.E.

sort -k2,2n -k3,3n

thanks,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]