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

This chapter is from the book

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.

  • + Share This
  • 🔖 Save To Your Account