- 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
Sort Contents by Date and Time
ls -t
Letters are great, but sometimes you need to sort a directory’s contents by date and time. To do so, use -t (or --sort=time) along with -l; to reverse the sort, use -tr (or --sort=time --reverse) along with -l. Using the reverse sort can be pretty handy—the newer stuff ends up at the bottom, which is easier to see, because that’s where your prompt will be when the command finishes!
$ ls -latr ~/ -rw------- 1 scott scott 8800 2015-10-18 19:55 .bash_history drwx------ 15 scott scott 1280 2015-10-18 20:07 .opera drwx------ 2 scott scott 80 2015-10-18 20:07 .gconfd drwxr-xr-x 2 scott scott 432 2015-10-18 23:11 .qt drwxr-xr-x 116 scott scott 5680 2015-10-18 23:11 . drwx------ 3 scott scott 368 2015-10-18 23:12 .gnupg drwxr-xr-x 12 scott scott 2760 2015-10-18 23:14 bin drwx------ 4 scott scott 168 2015-10-19 00:13 .Skype [list condensed and edited due to length]
All of these items except the last one were modified on the same day; the last one would have been first if you weren’t using the -r option and thereby reversing the results.