User Tools

Site Tools


blog:2010:1016_find_large_folder_in_command_line

Find large folder in command line

As the info du command state:

“du reports the amount of disk space used by the specified files and for each subdirectory (of directory arguments).”

It's really helpful when a partition get fill-up and you need to free some space.

If you want to check the size of folders present in your home directory for example, you can run this command: du –max-depth=1 -h ~

This is great, but it would be even better if the output what sorted by size.

Of course sort is the tool you need here and it now include the –human-numeric-sort option in it. This option is only new (it was had at the end of 2009) and present on the version 7.5 and above of core-utils (the package that contain du).

Here how to use it: du –max-depth=1 -h ~ | sort -rh

I like to combine all this with the head command to limit the output to display the by the command du –max-depth=1 -h ~ | sort -hr | head -n 10

blog/2010/1016_find_large_folder_in_command_line.txt · Last modified: by 127.0.0.1