Skip to main content
Tweeted twitter.com/StackUnix/status/1163058107049750528

how How do you sort du output by size?

edited tags
Link
Source Link
xenoterracide
  • 61.5k
  • 79
  • 196
  • 252

how do you sort du output by size?

How do you sort du -sh /dir/* by size? I read one site that said use | sort -n but that's obviously not right. Here's an example that is wrong.

[~]# du -sh /var/* | sort -n 0 /var/mail 1.2M /var/www 1.8M /var/tmp 1.9G /var/named 2.9M /var/run 4.1G /var/log 8.0K /var/account 8.0K /var/crash 8.0K /var/cvs 8.0K /var/games 8.0K /var/local 8.0K /var/nis 8.0K /var/opt 8.0K /var/preserve 8.0K /var/racoon 12K /var/aquota.user 12K /var/portsentry 16K /var/ftp 16K /var/quota.user 20K /var/yp 24K /var/db 28K /var/empty 32K /var/lock 84K /var/profiles 224M /var/netenberg 235M /var/cpanel 245M /var/cache 620M /var/lib 748K /var/spool