Re:[SOLVED] bash LC_COLLATE or LC_ALL set “C” not sort in dictionary order.
Edward Martinez
eam1edward at gmail.com
Wed Feb 1 09:52:22 UTC 2012
On 01/31/12 12:22, Robert Bonomi wrote:
> `
>
>
> Edward wrote:
>> On 01/31/12 06:31, Robert Bonomi wrote:
>>>> Hi,
>>>>
>>>> Been trying to get BASH to sort set characters in dictionary order.
>>>> I typed "locale" and it shows LC_COLLATE and LC_ALL are set to "C"
>>>> thought that was enough to work,
>>>> however when i type metacharacters: set character; any character,
>>>> something like this:
>>>>
>>>> ls [a-cx-y]*
>>>>
>>>> bash does not sort in dictionary order; file "Binarc" does not
>>>> list.
>>>>
>>> *OF*COURSE* it doesn't. Unix is _case_sensitive_. You specified a lower-
>>> case only (in the C locale) pattern. Naturally, it doesn't match a file
>>> with an upper-case character in it.
>>>
>>> Note: in the 'C' locale, characters are sorted on the underlying byte value.
>>> Thus you will get all the upper-case matches before any lower-case match.
>>>
>>> To get upper-and-lower case files in the C locale, you will have to use:
>>> ls [A-CX-Ya-cx-y]*
>>>
>>> IF you speciy a different charset for collating, you _may_ get upper/lower
>>> case characters sorted adjacently. See the specifications for the charset
>>> in question.
>>>
>>>
>> Thanks for reply!
>>
>> I meant LC_COLLATE being set to en_US.UTF-8 not C.
> AH. you lied (not necessarily maliciously, or intentionally) about the
> nature of the problem. disregard my rant.
>
> The short answer to the revised situation is 'it depends on how the charset
> collating sequence is deifined'. AND _which_ release of FreeBSD you are
> using, and thus which version of bash.
>
I have been digging around and discovered linux's bash is not
working correctly on this matter and numerous users have file bug
reports about it. FreeBSD's bash is fine:
https://bugs.archlinux.org/task/24553
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/120687
http://teaching.idallen.com/net2003/06w/notes/character_sets.txt
i will continue using either character classes and upper/lower case
charsets when defining wildcards
thanks for the help.
More information about the freebsd-questions
mailing list