Home > Articles > Open Source > Linux/UNIX/Open Source Operating Systems

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Reverse the Order Contents Are Listed

ls -r

If you don’t like the default alphabetical order that -l uses, you can reverse it by adding -r (or --reverse).

$ ls -lar ~/
-rw-r--r--    1 scott scott  4954 2015-09-13 19:46 .bashrc
-rw-r--r--    1 scott scott   428 2015-04-20 11:00 .bash_profile
-rw-r--r--    1 scott scott    69 2015-04-20 11:00 .bash_logout
-rw-------    1 scott scott  8800 2015-10-18 19:55 .bash_history
drwx------    2 root  root     72 2015-09-16 19:14 .aptitude
drwxr-xr-x    2 scott scott   200 2015-07-28 01:31 alias
[List condensed and edited due to length]

When you use -l, the output is sorted alphabetically based on the name of the files and folders; the addition of -r reverses the output, but is still based on the filename. Keep in mind that you can add -r virtually any time you use ls if you want to reverse the default output of the command and options you’re inputting.

  • + Share This
  • 🔖 Save To Your Account