

List files by their size in reverse orderīy default, it is sorted to put bigger files on the top.

When two files are of the same size, they are sorted alphabetically. rw-rw-r- 1 abhishek abhishek 4.9K Jun 2 20:09 gnome-console-voiceoverĭrwxrwxr-x 4 abhishek abhishek 4.0K Jun 2 22:09 lettersĭrwxrwxr-x 2 abhishek abhishek 4.0K Jun 2 22:09 words rw-rw-r- 1 abhishek abhishek 13K May 29 12:29 members.csv rw-rw-r- 1 abhishek abhishek 30K May 27 16:07 bash.pdf rw-rw-r- 1 abhishek abhishek 41K May 27 15:24 ads.txt rw-rw-r- 1 abhishek abhishek 45K May 24 09:03 apt-get.pdf

rw-rw-r- 1 abhishek abhishek 244K May 26 14:56 cronjob-cheatsheet.png This means now you can see files ordered by size in KB, MB, or GB. This option makes the output of the ls command displays the file size in human readable formats. That's good but you can make it better by adding the -h option. To sort files by size, use the option -S with the ls command. rw-rw-r- 1 abhishek abhishek 143 May 30 12:06 routes.yamlĭrwxrwxr-x 2 abhishek abhishek 4096 Jun 2 22:09 words rw-rw-r- 1 abhishek abhishek 12721 May 29 12:29 members.csv rw-rw-r- 1 abhishek abhishek 4943 Jun 2 20:09 gnome-console-voiceoverĭrwxrwxr-x 4 abhishek abhishek 4096 Jun 2 22:09 letters rw-rw-r- 1 abhishek abhishek 249773 May 26 14:56 cronjob-cheatsheet.png rw-rw-r- 1 abhishek abhishek 29983 May 27 16:07 bash.pdf rw-rw-r- 1 abhishek abhishek 45443 May 24 09:03 apt-get.pdf You can display files in the current directory in the long listing format so that you can see their size: :~/toto$ ls -l But it is used for sorting the content of files, not the files themselves. Why? I'll share it in detail with examples. However, you'll be more comfortable combining it with the options -h and -l: ls -lhS The -S option of the ls command sorts the files by size. If you want to find the biggest or smallest files in the current working directory, you can sort the files by size. Though you can see the sizes of the file, they are displayed alphabetically. Size is one of the attributes displayed by the ls -l command. Use the option -l and you can list the files and directories along with their attributes. The ls command is used for displaying the contents of a directory.
