␡
- List Files and Folders
- List the Contents of Other Folders
- List Folder Contents Using Wildcards
- View a List of Files in Subfolders
- View a List of Contents in a Single Column
- View Contents As a Comma-Separated List
- View Hidden Files and Folders
- Visually Display a File's Type
- Display Contents in Color
- List Permissions, Ownership, and More
- Reverse the Order Contents Are Listed
- Sort Contents by Date and Time
- Sort Contents by Size
- Express File Sizes in Terms of K, M, and G
- Display the Path of Your Current Directory
- Change to a Different Directory
- Change to Your Home Directory
- Change to Your Previous Directory
- Conclusion
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.