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: Eric Blake
Subject: Re: Does sort -2,3n work properly?
Date: Sat, 18 Jan 2014 09:46:38 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 01/18/2014 09:29 AM, Bartosz Gołaszewski wrote:
> 2014/1/17 Pádraig Brady <address@hidden>:
>> 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.
> 
> Thanks, that explains it!
> 
>> You probably want to compare multiple fields in sequence. I.E.
>>
>> sort -k2,2n -k3,3n
>>
>> thanks,
>> Pádraig.
> 
> I was actually checking some busybox compatibility issues.

In fact, it's possible to contrive corner cases where numeric sorting
DOES span fields:

$ printf '10210304\n20120403\n30102305\n' | sort -t0 -k2,3n --debug
sort: using ‘en_US.UTF-8’ sorting rules
sort: key 1 is numeric and spans multiple fields
30102305
  ____
________
20120403
  ____
________
10210304
  ____
________



-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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