FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 05-01-2012, 10:14 PM
John Hasler
 
Default ls sorting order change

Dan B. wrote:
> What controls the order that the ls command uses for sorting names?

LC_COLLATE. Set it to "C".
--
John Hasler


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 87397jo8fc.fsf@thumper.dhh.gt.org">http://lists.debian.org/87397jo8fc.fsf@thumper.dhh.gt.org
 
Old 05-02-2012, 12:57 AM
Wayne Topa
 
Default ls sorting order change

On 05/01/2012 03:10 PM, Dan B. wrote:

What controls the order that the ls command uses for sorting names?


On a fresh Squeeze installation, ls seems to ignore leading "."
characters (it no longer lists all "hidden" files adjacent to each
other) and to ignore capitalization differences.

It used to sort in standard/traditional Unix order (not ignoring any
characters, and ordering by order of characters in ASCII/etc. (as
opposed to by case-insensitive alphabetical order)).


What controls ls's sorting order?

I haven't set any locale environment variable specifically for the
collation order, but I don't know what base LANG=en_US.UTF-8 setting
does. Does "en_US" imply that new sorting order?


How do I tell ls to work the way I've seen it work for decades?



Well man ls says

" List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified."


Guess you could start there.
Hope this helps

Wayne


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4FA08677.6040301@gmail.com">http://lists.debian.org/4FA08677.6040301@gmail.com
 
Old 05-02-2012, 08:20 AM
Clive Standbridge
 
Default ls sorting order change

>
> On a fresh Squeeze installation, ls seems to ignore leading "."
> characters (it no longer lists all "hidden" files adjacent to each
> other) and to ignore capitalization differences.

Hi Daniel,

To list the hidden files, use the -a or -A option (the latter omits
. and ..). Maybe you had one of these in an alias on a previous
system?

Alternatively, if you want to see hidden files when you type "ls *"
you can set "shopt -s dotglob" (this is specific to bash).

--
Cheers,
Clive


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120502082050.GA4827@rimmer.localdomain">http://lists.debian.org/20120502082050.GA4827@rimmer.localdomain
 
Old 05-02-2012, 03:02 PM
Camaleón
 
Default ls sorting order change

On Tue, 01 May 2012 15:10:23 -0400, Dan B. wrote:

> What controls the order that the ls command uses for sorting names?

>From "man ls" → info coreutils 'ls invocation' anf here it can be read:

***
By default, the output is sorted alphabetically, according to the
locale settings in effect.(1) If standard output is a terminal, the
output is in columns (sorted vertically) and control characters are
output as question marks; otherwise, the output is listed one per line
and control characters are output as-is.

(1) If you use a non-POSIX locale (e.g., by setting `LC_ALL' to
`en_US'), then `ls' may produce output that is sorted differently than
you're accustomed to. In that case, set the `LC_ALL' environment
variable to `C'.
***

Depending on the version you're using this can vary.

> On a fresh Squeeze installation, ls seems to ignore leading "."
> characters (it no longer lists all "hidden" files adjacent to each
> other) and to ignore capitalization differences.

(...)

Can you post a sample of the command you issued and the ouput you got?

Greetings,

--
Camaleón


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: jnri98$iv6$4@dough.gmane.org">http://lists.debian.org/jnri98$iv6$4@dough.gmane.org
 
Old 05-02-2012, 07:07 PM
"Dan B."
 
Default ls sorting order change

Wayne Topa wrote:

On 05/01/2012 03:10 PM, Dan B. wrote:

What controls the order that the ls command uses for sorting names?
...
...


Well man ls says

" List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified."


Guess you could start there.


Yes, I did look at the manual page and saw that text. However, that
didn't say anything about which definition of "alphabetical" ls uses.

Daniel


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4FA185F8.6090001@kempt.net">http://lists.debian.org/4FA185F8.6090001@kempt.net
 
Old 05-02-2012, 07:08 PM
"Dan B."
 
Default ls sorting order change

Sven Joachim wrote:

On 2012-05-01 21:10 +0200, Dan B. wrote:


What controls the order that the ls command uses for sorting names?


The locale or more specifically, the LC_COLLATE setting. See locale(7).

> ...

.. LC_COLLATE=C for many years.


Thanks.

Daniel



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4FA1862B.1050804@kempt.net">http://lists.debian.org/4FA1862B.1050804@kempt.net
 
Old 05-02-2012, 07:28 PM
"Dan B."
 
Default ls sorting order change

Camalen wrote:

On Tue, 01 May 2012 15:10:23 -0400, Dan B. wrote:
...


On a fresh Squeeze installation, ls seems to ignore leading "."
characters (it no longer lists all "hidden" files adjacent to each
other) and to ignore capitalization differences.


(...)

Can you post a sample of the command you issued and the ouput you got?


It was like (using made-up names):

.aaa
bbb
ccc
DDD
EEE
.fff

when I expected:

.aaa
.fff
DDD
EEE
bbb
ccc


(The first order is a typical order for English (case-insensitive, and
ignoring punctuation), so now it makes sense that my default locale
setting (LANG=en_US.UTF-8) yielded that order.

The second order is plain old ASCII(/ISO-8859-x/Unicode) character
order with no special treatment (ignoring or case-mapping) of
characters--and setting LC_ALL=C (or LC_COLLATE=C) does indeed yield that
order.

I guess now I need to figure out where I might like to see things in
the "new" order vs. where I still want to see things in LC_COLLATE=C
order.)

Daniel





--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4FA18AE1.5010006@kempt.net">http://lists.debian.org/4FA18AE1.5010006@kempt.net
 
Old 05-03-2012, 04:48 PM
Camalen
 
Default ls sorting order change

On Wed, 02 May 2012 15:28:33 -0400, Dan B. wrote:

> Camalen wrote:
>> On Tue, 01 May 2012 15:10:23 -0400, Dan B. wrote: ...
>>
>>> On a fresh Squeeze installation, ls seems to ignore leading "."
>>> characters (it no longer lists all "hidden" files adjacent to each
>>> other) and to ignore capitalization differences.
>>
>> (...)
>>
>> Can you post a sample of the command you issued and the ouput you got?
>
> It was like (using made-up names):
>
> .aaa
> bbb
> ccc
> DDD
> EEE
> .fff
>
> when I expected:
>
> .aaa
> .fff
> DDD
> EEE
> bbb
> ccc

Let's see:

sm01@stt008:~/Desktop/test$ locale
LANG=es_ES.UTF-8
LC_CTYPE="es_ES.UTF-8"
LC_NUMERIC="es_ES.UTF-8"
LC_TIME="es_ES.UTF-8"
LC_COLLATE="es_ES.UTF-8"
LC_MONETARY="es_ES.UTF-8"
LC_MESSAGES="es_ES.UTF-8"
LC_PAPER="es_ES.UTF-8"
LC_NAME="es_ES.UTF-8"
LC_ADDRESS="es_ES.UTF-8"
LC_TELEPHONE="es_ES.UTF-8"
LC_MEASUREMENT="es_ES.UTF-8"
LC_IDENTIFICATION="es_ES.UTF-8"
LC_ALL=

So this is the default "ls" sorting:

sm01@stt008:~/Desktop/test$ ls -la
total 1
drwxr-xr-x 2 sm01 sm01 192 may 3 18:33 .
drwxr-xr-x 10 sm01 sm01 816 may 3 18:32 ..
-rw-r--r-- 1 sm01 sm01 0 may 3 18:32 .aaa
-rw-r--r-- 1 sm01 sm01 0 may 3 18:32 bbb
-rw-r--r-- 1 sm01 sm01 0 may 3 18:32 ccc
-rw-r--r-- 1 sm01 sm01 0 may 3 18:33 DDD
-rw-r--r-- 1 sm01 sm01 0 may 3 18:33 EEE
-rw-r--r-- 1 sm01 sm01 0 may 3 18:33 .fff

While changing the locale:

sm01@stt008:~/Desktop/test$ LANG=C ls -la
total 1
drwxr-xr-x 2 sm01 sm01 192 May 3 18:33 .
drwxr-xr-x 10 sm01 sm01 816 May 3 18:43 ..
-rw-r--r-- 1 sm01 sm01 0 May 3 18:32 .aaa
-rw-r--r-- 1 sm01 sm01 0 May 3 18:33 .fff
-rw-r--r-- 1 sm01 sm01 0 May 3 18:33 DDD
-rw-r--r-- 1 sm01 sm01 0 May 3 18:33 EEE
-rw-r--r-- 1 sm01 sm01 0 May 3 18:32 bbb
-rw-r--r-- 1 sm01 sm01 0 May 3 18:32 ccc

> I guess now I need to figure out where I might like to see things in the
> "new" order vs. where I still want to see things in LC_COLLATE=C order.)

Is that "that new"? The above output is from my Lenny system and that was
the default setup two years ago :-?

Greetings,

--
Camalen


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: jnuctq$78r$7@dough.gmane.org">http://lists.debian.org/jnuctq$78r$7@dough.gmane.org
 
Old 05-03-2012, 05:26 PM
"Dan B."
 
Default ls sorting order change

Camalen wrote:

On Wed, 02 May 2012 15:28:33 -0400, Dan B. wrote:
...

I guess now I need to figure out where I might like to see things in the
"new" order vs. where I still want to see things in LC_COLLATE=C order.)


Is that "that new"? The above output is from my Lenny system and that was
the default setup two years ago :-?


No, it's not really that new--just new to me because I got far behind
in upgrading/updating my Debian system. (That's why I used quotes--to
show that I didn't really mean the usual sense of new.)



Daniel



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4FA2BFB9.1060701@kempt.net">http://lists.debian.org/4FA2BFB9.1060701@kempt.net
 

Thread Tools




All times are GMT. The time now is 07:18 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org