Alphabetizing names in `ls` alias with .files not intermingled

I am currently using the following ls alias: alias ls='ls -alhGkpsq --color=auto'. This results in following directory listing.

[03:35] bryson@brys  ~ :$ ls
total 48K
4.0K drwx------ 4 bryson 4.0K Nov  2 03:34 ./
8.0K drwxr-xr-x 3 root   4.0K Apr 19  2012 ../
4.0K -rw------- 1 bryson  676 Nov  2 03:35 .bash_history
8.0K -rw-r--r-- 1 bryson   21 Nov 23  2011 .bash_logout
8.0K -rw-r--r-- 1 bryson   57 Nov 23  2011 .bash_profile
4.0K -rw------- 1 bryson   50 Nov  2 03:34 .lesshst
4.0K drwxr-xr-x 3 bryson 4.0K Nov  2 03:21 source/
4.0K drwx------ 2 bryson 4.0K Nov  2 03:23 .ssh/
4.0K -rw------- 1 bryson 1.6K Nov  2 03:23 .viminfo

The issue I have with this, which is not an issue with OS X’s version of ls, is that .ssh/ is alphabetized ignoring the . in the filename.

What I would like is for ls to alphabetize the dot files all together at the top, which is where it puts . and .. as well. (Arch Linux, Bash)

Answer

Probably caused by your locale, but if you do:

LC_COLLATE=C ls -F --color=auto -l

The dot files are sorted correctly

Attribution
Source : Link , Question Author : Bryson , Answer Author : daisy

Leave a Comment