Human-friendly sorted du output

Using the following one-liner, get a human-friendly overview of the size of the files and directories in the current directory, sorted by size.

du -d1 . | sort -n | xargs -I myline python -c "from math import log;ss='myline'.split();n=int(ss[0]);k=1024.;d=int(log(n)/log(k));print '{:10.2f} {}B\t{}'.format(n/k**d, ['K','M','G','T','P'][d], ' '.join(ss[1:]))"

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>