ls
is required by POSIX to sort the file names in its output according to the collating sequence in the current locale.
If your system has no locale where the sort order ignores case at least in the first pass of comparing strings, you could try piping to sort -f
:
ls -q | sort -f
(with the -q
option to guarantee file names are displayed on one line by replacing control characters in them including newline with ?
(beware that may affect the order).
Or with the zsh shell, use something like:
lc() REPLY=$REPLY:l
print -rC1 -- *(o+lc)
Instead of ls
. That is define a lc
helper function that changes the value of $REPLY
to lower case, and use that as an o
rdering function for the glob expansion (not necessarily strictly equivalent to a case-insensitive comparison, but should be close enough especially for ASCII only text).