The beauty of *nix tools is you can combine them:
ls -l | sort -k9,9
The output of ls -l
will look like this
-rw-rw-r-- 1 luckydonald luckydonald 532 Feb 21 2017 Makefile
-rwxrwxrwx 1 luckydonald luckydonald 4096 Nov 17 23:47 file.txt
So with 9,9
you sort column 9
up to the column 9
, being the file names. You have to provide where to stop, which is the same column in this case. The columns start with 1
.
Also, if you want to ignore upper/lower case, add --ignore-case
to the sort command.