How to List All Files Ordered by Size in Linux
This articles about listing files using the popular ls command, we covered how to list and sort files by last modification time (date and time) in Linux.
To list all files in a directory, open a terminal window and run the following command. Note that when ls invoked without any arguments, it will list the files in the current working directory.
$ ls -la OR $ ls -la /var/www/html/eduguru/
To list all files and sort them by size, use the
-S option. By default, it displays output in descending order (biggest to smallest in size).
$ ls -laS
You can output the file sizes in human-readable format by adding the
-h option as shown.
$ ls -laSh
And to sort in reverse order, add the -r flag as follows.
$ ls -laShr
Besides, you can list sub directories recursively using the
$ ls -laShR
For any query or issue, feel free to discuss on http://discuss.eduguru.in