[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why sort is differently on different machine?
From: |
Eric Blake |
Subject: |
Re: Why sort is differently on different machine? |
Date: |
Wed, 02 May 2012 07:19:02 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120424 Thunderbird/12.0 |
On 05/01/2012 06:35 PM, Peng Yu wrote:
> Hi,
>
> 'sort' behaves differently on linux and Mac OS X (see below). Does
> anybody know why there is a difference and how to make them the same?
Most likely due to a difference in the locale definitions on the two
machines, in which case 'LC_ALL=C sort' will make them behave the same,
or you can define a custom locale (with localedef) that has the same
rules for both machines instead of relying on the pre-built en_US.UTF-8
locale. See the FAQ:
https://www.gnu.org/software/coreutils/faq/#Sort-does-not-sort-in-normal-order_0021
>
> ~$ uname
> Linux
> ~$ (echo AA;echo Aa)|sort
> Aa
> AA
> ~$ locale
> LANG=en_US.UTF-8
> LC_COLLATE="en_US.UTF-8"
>
> ~$ uname
> Darwin
> ~$ (echo AA;echo Aa)|sort
> AA
> Aa
> ~$ locale
> LANG="en_US.UTF-8"
> LC_COLLATE="en_US.UTF-8"
You are indeed using the same locale name on both machines, but since
the two machines do not have the same locale definitions (one is from
glibc, the other from BSD heritage), they are not identical definitions,
and apparently they differ on whether 'a' comes before or after 'A' in
English.
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature