I use an underscore at the beginning of file and folder names to mark them as something "special". But this sorting doesn't work for the most programs under Linux. I tried LC_COLLATE=C ls
and other locales but the results are something strange. Let's say I have these folders:
2
A
_F
G
K
S
x4
This is the sort order of ls
. When I use LC_COLLATE=C ls
, I have this:
2
A
G
K
S
_F
x4
I have this under Xubuntu 18.04 using the xfce-terminal-emulator on 2 machines.
What is wrong here?
You can sort files with leading underscores to the end with
--sort=version
or-v
which is equivalent tosort -V
(natural version sort) (which is most useful for sorting files with numbers).Details on version sorting are in
info ls
... note that:Perhaps this is adequate for your purpose.
@Zanna's answer provides one solution. Another solution is this: