how to list file and sort by filename using ls

Ben Scott dragonhawk at gmail.com
Mon Apr 24 16:49:01 EDT 2006


On 4/24/06, Zhao Peng <greenmt at gmail.com> wrote:
> output of echo $LANG:
>
>     en_US.UTF-8
>
> "LANG=C ls -ul" does do what I expected to do.
>
> What does "C" mean? character?

  "C" means "C", as in "the C programming language".  When you say
"LANG=C", you tell the system you want the old-fashioned sort order
based on encoded character values (typically ASCII) that C always
used.  With LANG=C, the system isn't locale or language aware, and
just does a simple numeric comparison of characters.  This means, for
example, that capital letters sort before lowercase letters.  This
tends to fail miserably with non-Latin character sets (i.e., not US or
Western Europe).

  With "LANG=en_US.UTF-8", the system is being told two things.  One,
the sort order should be as proper for the English language in the US.
 (That means case-insensitive sorts and such.)  Second, character
encoding should be assumed to be UTF-8.  UTF-8 is a method of encoding
Unicode characters which is backwards-compatible with ASCII.  Anything
which is legal ASCII encodes to the same value in UTF-8; higher order
characters (which are never legal in ASCII) get encoded using multiple
bytes (varying lengths, depending on the Unicode character).

-- Ben




More information about the gnhlug-discuss mailing list