Red Hat Bugzilla – Bug 149983
ls missing option to list directories first
Last modified: 2007-11-30 17:07:06 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.1) Gecko/20040707
Description of problem:
The good old 'ls' command has many options but there are missing some essential things.
1. There is no option to get a properly ascii sorted output (see examples below). Instead it relies on the LANG variable
2. On HP-UX a regular 'ls' done as super-user always lists all files (except . and ..). There is no option for this on Linux.
3. There is no option to get directories before files (like windows does it)
Version-Release number of selected component (if applicable):
Steps to Reproduce:
just do an 'ls' or 'ls -a'
Actual Results: LANG=en_US ls -a
. .B !!CTestFile eTestFile .g
.. bTestFile .d !eTestFile !!GdTestFile
.a !bTestFile dTestFile @eTestFile gTestFile
aTestFile @bTestFile !dTestFile .f !gTestFile
!aTestFile .c @dTestFile fTestFile @gTestFile
@aTestFile cTestFile @DTestFile !fTestFile
@ATestFile !cTestFile .e @fTestFile
.b @cTestFile .E !FTestFile
Expected Results: root ls under HP-UX
!!CTestFile !eTestFile .c @aTestFile aTestFile
!!GdTestFile !fTestFile .d @bTestFile bTestFile
!FTestFile !gTestFile .e @cTestFile cTestFile
!aTestFile .B .f @dTestFile dTestFile
!bTestFile .E .g @eTestFile eTestFile
!cTestFile .a @ATestFile @fTestFile fTestFile
!dTestFile .b @DTestFile @gTestFile gTestFile
> 1. There is no option to get a properly ascii sorted output (see examples
below). Instead it relies on the LANG variable
You can set the LC_COLLATE=C variable to get ASCII sorting without affecting
other locale variables (see POSIX).
> 2. On HP-UX a regular 'ls' done as super-user always lists all files (except .
and ..). There is no option for this on Linux.
I think the -A option does what you want.
> 3. There is no option to get directories before files (like windows does it)
This feature enhancement has been requested previously, for example:
I also would like an option to sort directories first, but it seems
that coreutils people dislike it and ignores every patch or message
that suggests this addition (which is quite trivial).
The main objection I think is that sort-directories-first isn't orthorgonal to
In other words: What if someone wants this option, but with things sorted on
size or extension, rather than on name?
Closing as 'upstream', since this issue is known to the upstream developers.