------------------------------------------------------------------------------- Disk usage Example output... (contains tabs) # du . > du_list.txt 12 ./a 4 ./b/B 6 ./b 32 ./c/C 36 ./c 2 ./d/D 4 ./d 58 . NOTE the parent is after its children (depth first) and the value includes the values of all the children plus the contents of that directory as well. EG: in the above b/B is 4 and b is 6 so the directory b itself contains 2 which is not in a sub-directory. An alternative with a lot more information is to convert the output of "find -ls" to a hierarchical data tree. OR better still use tree --du tree -h --du There is a very small awk script that does simular /home/anthony/store/scripts/system/du_tree Sorting (humanised)... du -sh * | sort -rh ------------------------------------------------------------------------------- DU of file counts (not sizes) You may also like to look at "tree" (recursive directory listing) but includes a final summery of directory and file counts. ALL Directory & File counts... The --inodes counts the number of filenames (files and directories) that are present in a directory and sub-directory. du --inodes .cache An empty directory counts as 1 Files Only... This gets you the number of actual files, in each directory. But does not list the sub-directories. Nothing is output for directories without any files. WARNING: fails on filenames containing newlines. find -type f | awk -F/ '{a[$2]++} END { for(i in a){printf "%d\t%s\n", a[i], i; }}' | sort -n Sub-Directory counts... This gets you the sub-directories (at least 1 for '..'), for each directory. WARNING: fails on filenames containing newlines. find -type d | awk -F/ '{a[$2]++} END { for(i in a){printf "%d\t%s\n", a[i], i; }}' | sort -n ------------------------------------------------------------------------------- Graphical Du The different stles viewing formats are defined in Visualization of large tree structures http://www.randelshofer.ch/treeviz/ xdiskusage - http://xdiskusage.sourceforge.net/ Is better looking that 'xdu' and can take a du output text file. Essentually a updated "xdu" -- RECOMMENDED xdiskusage directory xdiskusage du_output.txt ssh remote du | xdiskusage - # file counts... du --inodes | xdiskusage - xdu (there is an old one and also a gtk version) The oldest and original from the ancient Xorg applications archive. The gtk has nicer output but still very raw. Display is ugly with, and is known as a 'Icicle Tree' xdu < du_list.txt If a directory entry is missing (like '.') it will add up the components And will also handle a unsorted list! It does not need to be depth-first! The program does not itself perform a "du", but takes the output of "du". Being able to do this is useful as it means the program can also be used to graphically display other forms of nested output, and not just disk usage! Also it means I can do a "du" on a system that does not have graphical output, and then display it locally. Or store a "du" output for later comparison to see how a directory is changing. baobab - http://www.marzocca.net/linux/baobab.html Gnome disk usage... Can itself "du" a local or remote file system. It can display as a tree list (icicle), circular (sunburst), or boxed (treemap) view. *** Does NOT take DU output. *** -- Arrrgghhh... filelight (fedora package KDE dependancies) KDE displaying disk usage as 'sunburst' - HTML manual But has a nicer responsing display. *** Does NOT take DU output. *** duc - http://duc.zevv.nl/ Command, Curses, X window, and CGI interfaces Generates a disk (sunburst) view (from debian) Can store infomation in a database ("db" file) for later direct use. *** Does NOT take DU output. *** qdirstat k4dirstat kdirstat Generates a box view (treemap). qdirstat also includes a bar chart *** Does NOT take DU output. *** JDiskReport Pie chart version written in java TkDu - https://github.com/daniel-beck/tkdu https://web.archive.org/web/20080401095740/http://unpythonic.net/jeff/tkdu/ Generate a indenting box view of disk usage Written in python, and using tkintper (python Tk interface) * must be a full hierarchy - with all files included (du -ak) * comments not allowed * top level total is NOT displayed *** Takes a LIMITED du output *** fsv - http://fsv.sourceforge.net/ 3d graphical Du (not looked at yet) agedu -- generates a file, that it can read and create a Temporary webpage displaying bar graph usage with color showing how much AND how old data is. (low dependancies) Example: agedu -s . -o user.agedu agedu -w -f user.agedu --files gdmap - Box Graphical Disk Analyser no longer included in RpmFusion repos since F22 ------------------------------------------------------------------------------- Curses Terminal output ncdu - https://dev.yorhel.nl/ncdu (fedora package available) Curses Du -- bar charts of total amounts decending only shows results of that sub-directory Can du a specific directory, export results, and read those back in BUT can NOT read a normal du output file! gt5 - http://gt5.sourceforge.net/ Esentually a DU to HTML convertor, with size diff capability Du output saved, and then converted to HTML (with file index jumps) The HTML output is then displayed in a lynx editor gt5 dir # du output is cached for later run. gt5 list.du Can report differences in directory size if given two files gt5 old.du new.du The html is saved in ~/.gt5.html (a VERY LONG file with index jumps) And old du outputs are in ~/.gt5_diffs tdu - https://webonastick.com/tdu/ directory folding curses du output (not looked at) tdu - https://bitbucket.org/josephpaul0/tdu/src/master/ curses directory summery and largest files. (not looked at) ------------------------------------------------------------------------------- Sorting human readable du output https://serverfault.com/questions/62411/how-can-i-sort-du-h-output-by-size Using GNU coreutil 7.5 (Aug 2009) du -hs * | sort -h Do the DU, sort it, then use awk to make human readable FYI: Kbyte => 1024 => 2**10 Mbyte => 2**20 Gbyte => 2**30 du -B1 | sort -nr | awk 'BEGIN { hum[2**30]="G"; hum[2**20]="M"; hum[2**10]="K"; } { sum=$1; for (x=2**30; x>=1024; x/=1024){ if (sum>=x) { printf "%.1f%s\t\t",sum/x,hum[x]; print $2; break } } }' From Adam Bellaire (Perl Monk) Sort human readable output using perl du -h | perl -e ' %h=(K=>10,M=>20,G=>30); sub h{ ($n,$u) = shift =~ /([0-9.]+)(\D)/; return $n * 2**$h{$u} } print sort {h($b)<=>h($a)} <>; ' After some reworking... perl -e ' %h = map{ /.\s/; 99**(ord$&&7)-$` , $_ } `du -h`; print @h{ sort %h }; ' Explaination! $& is 0,K,M,G ord('0') => 48 &7 => 0 ord('K') => 75 &7 => 3 ord('M') => 77 &7 => 5 ord('G') => 71 &7 => 7 so 99**(ord$&&7) minus the value ($`) is a sortable value This is a crazy HACK, and so obtuse that I don't recommend it! -------------------------------------------------------------------------------