I am trying to find a way to have the results of an ls command be printed in a case insensitive manner.
currently an ls command results in:
Apple
Boy
Chart
Dock
apples
boys
charts
docks
what i want is this:
Apple
apples
Boy
boys
Chart
charts
Dock
docks
is this possible?
As a follow up to [Keith Thompson]'s answer, I tested on a Linux system and LC_COLLATE=C did not work for me, but LC_COLLATE="en_US.UTF-8" did. I put the following in my startup script:
This did not work on OS X.
ls
(at least if you're using the GNU coreutils version;ls --version
to check that) sorts file names according to the current locale.The set of available locales varies from system to system (
locale -a
for a list), but on my system this:sorts names with
a
andA
beforeb
andB
-- though it might not be exactly in the order you're looking for.This works even when
ls
lists files in multiple columns, something that's difficult to do withsort -f
.(I have
$LC_COLLATE
set toC
specifically so that locale-sensitive sorting is done in ASCII order.)Just pipe the result to
sort -f
.Add to .profile:
then you can use following command: