␡
- 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
Sort Contents by Size
ls -S
You can also sort by size instead of alphabetically by filename or extension, or by date and time. To sort by size, use -S (or --sort=size).
$ ls -laS ~/ -rw-r--r-- 1 scott scott 109587 2015-10-19 11:53 .xsession-errors -rw------- 1 scott scott 40122 2015-04-20 11:00 .nessusrc -rw-r--r-- 1 scott scott 24988 2015-04-20 11:00 .abbrev_defs -rwxr--r-- 1 scott scott 15465 2015-10-12 15:45 .vimrc -rw------- 1 scott scott 11794 2015-10-19 10:59 .viminfo -rw------- 1 scott scott 8757 2015-10-19 08:43 .bash_history [List condensed and edited due to length]
When you sort by size, the largest items come first. To sort in reverse, with the smallest at the top, just use -r.