Reverse order sort du -h human-readable output

du -d 1 -h | perl -e'%h=map{/.\s/;99**(ord$&&7)-$`,$_}`du -d 1 -h`;die@h{reverse sort%h}'

MacBook-Pro.-=[jnevans] /var/log # sudo ~jnevans/sortd.sh
192K ./cups
728K ./krb5kdc
2.1M ./DiagnosticMessages
 11M ./asl
 22M .

Hat tip to http://serverfault.com/questions/62411/how-can-i-sort-du-h-output-by-size

Want it in your .bashrc?

alias dsize='du -d 1 -h | perl -e'"'"'%h=map{/.\s/;99**(ord$&&7)-$`,$_}`du -h`;die@h{reverse sort%h}'"'"
This entry was posted in Programming. Bookmark the permalink.