Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using ubuntu (natty), and when I use ls -l, the files are listed, but apparently the sorting algo ignores any special characters. For ages I've used underscores to mark special folders. And it seems to me, that they were always listed first.

Now, the underscore is completely ignores.

Let's assume that I have the files fileA, _fileB and fileC in a folder. Currently, ls -l orders them like so:

malbert@dredg:/tmp/1$ ls -l
total 0
-rw-r--r-- 1 malbert domain users 0 2011-08-03 15:27 fileA
-rw-r--r-- 1 malbert domain users 0 2011-08-03 15:27 _fileB
-rw-r--r-- 1 malbert domain users 0 2011-08-03 15:27 fileC

But I'd like it to be sorted like follows:

malbert@dredg:/tmp/1$ ls -l
total 0
-rw-r--r-- 1 malbert domain users 0 2011-08-03 15:27 _fileB
-rw-r--r-- 1 malbert domain users 0 2011-08-03 15:27 fileA
-rw-r--r-- 1 malbert domain users 0 2011-08-03 15:27 fileC

I've dug through the ls man page and could not find anything. Is there somewhere a system-wide collation option? Or something the like?

share|improve this question
    
Are you sure you do not have something like alias ls='ls -U' in your startup script ? –  jfgagne Aug 3 '11 at 14:27

1 Answer 1

up vote 4 down vote accepted

I imagine it obeys the setting of LC_COLLATE in your environment or, in the absence of that, the setting of LC_ALL or LANG instead.

The locale(1) command should tell you what settings a program will see, given your environment.

share|improve this answer
    
Yes. Setting LC_COLLATE to C fixed it. Thanks a bunch :) –  exhuma Aug 5 '11 at 6:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.