Site icon LinuxCommands.site

How to sort by size using the du command

The default options of the linux du command are not sorted according to the size of the disk.

If you want to display the results of du according to the disk usage size, you need to use the pipe and sort commands.

In the following example, we will use the du command to display the file and directory disk usage in the current directory, and then use the sort command through the pipeline to sort the results.

➜  ~ du -d 1 | sort -n -r

Exit mobile version