how to sort according to size of subdirectories when using du -sh * command?

6.8k Views Asked by At
du -sh *
275M    fusionforge_g
50M     git
99M     httpd
181M    php-doc
4.0M    pirate3
3.4G    qt
1.1M    vim-addon-manager
126M    wp-and

this output is out of order now, how to make this output ordered according to the size of subdirectories?

@vstm the version of my core util is less than 7.5, so the solution in https://serverfault.com/questions/62411/how-can-i-sort-du-h-output-by-size cannot solve my problem.

rpm -qa | grep core
coreutils-5.97-19.el5
policycoreutils-1.33.12-14.2.el5

@Leonid Volnitsky sort -nr not works when -h option is used:(

du -sh * | sort -nr
275M    fusionforge_g
181M    php-doc
126M    wp-and
99M     httpd
50M     git
4.0M    pirate3
3.4G    qt
1.1M    vim-addon-manager
1

There are 1 best solutions below

5
On

Something like this:

  command du -sh */ | sort -nrh