0

When trigger ls -alhF I see .ssh got placed near ssl instead of top of the list. How could I make ls to sort files and folders to be "native" (aka .ssh/ then abd-dir/ then ssl/ dir)

[centos@ip-172-31-46-255 ~]$ ls -alhF
total 88M
drwx------. 17 centos centos 4.0K Feb 17 15:18 ./
drwxr-xr-x.  3 root   root     20 Nov 18 16:31 ../
-rw-rw-r--.  1 centos centos 8.9M Mar 19  2016 apache-tomcat-8.0.33.tar.gz
-rw-------.  1 centos centos  21K Feb 17 11:38 .bash_history
-rw-r--r--.  1 centos centos   18 Oct 31  2018 .bash_logout
-rw-r--r--.  1 centos centos  295 Nov 18 22:22 .bash_profile
-rw-r--r--.  1 centos centos  231 Oct 31  2018 .bashrc
drwx------.  4 centos centos   37 Nov 19 00:54 .config/
drwxrwxr-x.  2 centos centos   28 Dec 11 15:41 cronjob/
drwxrwxr-x.  8 centos centos  139 Dec 13 09:28 deploy/
drwxrwxr-x.  5 centos centos  106 Feb 17 15:18 dotfiles/
-rw-r--r--.  1 root   root    27M May 16  2018 elasticsearch-2.3.1.deb
-rw-r--r--.  1 root   root    26M May 16  2018 elasticsearch-2.4.6.deb
-rw-r--r--.  1 root   root    26M May 16  2018 elasticsearch-2.4.6.rpm
drwxrwxr-x.  3 centos centos   19 Nov 27 23:44 .java/
-rw-rw-r--.  1 centos centos  26K Apr 25  2019 mysql80-community-release-el7-3.noarch.rpm
drwxrwxr-x.  4 centos centos   31 Dec  3 07:54 nginx/
drwxrwxr-x.  3 centos centos   20 Nov 19 01:18 .node-gyp/
-rw-------.  1 centos centos   17 Nov 19 01:16 .node_repl_history
drwxrwxr-x.  7 centos centos  119 Nov 27 23:01 .npm/
drwxrwxr-x.  5 centos centos   74 Feb 17 10:36 .nvm/
drwxrwxr-x. 17 centos centos 4.0K Feb 15 10:06 om_app/
drwxrw----.  3 centos centos   19 Nov 18 22:20 .pki/
drwxrwxr-x.  5 centos centos  199 Feb 15 10:07 .pm2/
-rw-------.  1 centos centos  449 Dec 12 12:00 .rediscli_history
-rw-------.  1 centos centos 1.0K Nov 29 10:44 .rnd
drwx------.  2 centos centos   29 Nov 18 16:31 .ssh/
drwxr-x---.  3 centos centos  203 Dec  3 07:34 ssl/
drwxr-xr-x.  2 centos centos   24 Feb 17 10:05 .vim/
-rw-------.  1 centos centos 5.8K Feb 17 15:18 .viminfo
Luke
  • 101
  • Welcome to the site. From your sample output, I infer that you are using CentOS, but please edit your question to include specific information on the OS type and version, as this may have influence on this kind of strongly "environment-dependent" behaviour. – AdminBee Feb 17 '20 at 08:32
  • Related questions are https://unix.stackexchange.com/q/328185/5132 , https://unix.stackexchange.com/q/417678/5132 , https://unix.stackexchange.com/q/35469/5132 , and https://unix.stackexchange.com/q/517718/5132 . – JdeBP Feb 17 '20 at 08:44
  • Also https://unix.stackexchange.com/q/288333/86440. – Stephen Kitt Feb 17 '20 at 09:08

1 Answers1

0

Use a collation which doesn’t apply weights to different character classes, e.g. the C collation which only sorts on character positions:

LC_ALL=C ls -alhF
Stephen Kitt
  • 434,908
  • Or LC_COLLATE as in https://unix.stackexchange.com/a/417679/5132 . (-: – JdeBP Feb 17 '20 at 08:47
  • @JdeBP except that LC_COLLATE isn’t a surefire answer — LC_ALL trumps it, and LC_CTYPE can cause issues with it. (And yes, I am aware I edited the linked answer.) – Stephen Kitt Feb 17 '20 at 08:48