Combine the best of ‘du’ and ‘tree’

disk-usagetree

I'm wondering if we can combine the honesty of 'du' with the indented formatting of 'tree'. If I want a listing of the sizes of directories:

du -hx -d2

…displays two levels deep and all the size summaries are honest, but there's no indenting of subdirs. On the other hand:

tree --du -shaC -L 2

…indents and colorizes nicely however the reported sizes are a lie. To get the real sizes one must:

tree --du -shaC

…which is to say that you only get the true sizes if you let 'tree' show you the entire directory structure. I'd like to be able to always have correct size summaries regardless of how many levels of subdirs I want to actually display. I often do this:

tree -du -shaC | grep "\[01;34m"

… which prunes out everything but directories, and indents them nicely … but there's no easy way to limit the display to just a given number levels (without the summaries lying). Is there a way? Perhaps I've missed the correct switches …

Best Answer

Also checkout ncdu: http://dev.yorhel.nl/ncdu

Its page also lists other "similar projects":

gt5 - Quite similar to ncdu, but a different approach.

tdu - Another small ncurses-based disk usage visualization utility.

TreeSize - GTK, using a treeview.

Baobab - GTK, using pie-charts, a treeview and a treemap. Comes with GNOME.

GdMap - GTK, with a treemap display.

Filelight - KDE, using pie-charts.

KDirStat - KDE, with a treemap display.

QDiskUsage - Qt, using pie-charts.

xdiskusage - FLTK, with a treemap display.

fsv - 3D visualization.

Philesight - Web-based clone of Filelight.

Related Question