I'm trying to figure out how to list the contents of a directory in the following group order:
- Hidden directories
- Non-hidden directories
- All other hidden files (including regular files, symlinks, sockets)
- All other non-hidden files (including regular files, symlinks, sockets)
Each group should be sorted A-Z, preferably case-insensitive.
Based on this answer I tried the following:
ls -dlU .*/ */
This gets me half-way there by listing hidden directories and then non-hidden directories. The problem is it doesn't list any files.
I've also tried various ways of piping the output to sort
with no luck.
How can I do this?
LC_COLLATE=C ls -lA --group-directories-first
orLANG=POSIX ls -lA --group-directories-first
. Though it works on my system (en-US.UTF-8
), it sorts case-sensitive and would probably have some strange effects on systems with different locales/foreign characters.C
but case insensitive or based onen_US
but dot-sensitive). Yeah, I know this is half a year later but I stumbled upon this question while looking for some similar stuff...