gt5 - a diff-capable 'du-browser'

Overview

Years ago, I was proud to own an 80MHz, 16MB RAM PC with a huge 512MB harddisk. But even on this incredibly huge harddisk, my diskspace seemed to disappear over time. So I wrote a little tool to find out where all my diskspace had gone: I called it gettree, as it showed all files in a directory and also calculated the size of subtrees. Over the years, the OS I used changed, but the problem stayed. Using Linux, there are some tools to deal with it, but I couldn't find anything that was clearly laid out, intuitive to browse, and doesn't need X-Windows.

Features

  • displays the diskspace used by files and directories within a directory
  • displays what has happened since gt5 last ran (see screenshot below)
  • optionally provides links to the files, so you can also browse them
  • displays entries with their size and the percentage of their parent
  • omission of small files/directories to keep the results readable
  • easy browsing through subdirectories, using the cursor-keys

Implementation

I tried different ways to do the job and settled on a small shell-script:
  • highly 'portable', as it only depends on some GNU-utilities
  • common textbrowsers are used to navigate through the results
  • runs on console, xterm or remotely over ssh

Screenshot

Navigation

If you are familiar with textbrowsers there is nothing to say: gt5 produces an HTML file; go browse it. Below are the most important keys for gt5 used with links/links2/elinks/lynx:
browsing in generalmeaning in gt5
Cursor Leftgo backgo one directory up
Cursor Rightfollow linkopen selected directory
Cursor Up/Downgo to link above/belowmove Cursor Up/Down
Insert/Deletescroll page up/downscroll page up/down
Ctrl-Cquit textbrowserquit gt5

Usage

Syntax: gt5 [ dir | file | dir file | file file2 ] [options]
     dir           the directory you want to check for space used
     file/file2    existing du-logs (du -akx $DIR #gz/bz2/plain)
   --cut-at float  don't show files below 'float'% of its parent,
                   default is 0.1, use values between 0.01 and 30
   --diff-dir d    use dir d to store diffs between runs [~/.gt5-diffs]
   --discard       do not save this one for diffs, discard it
   --link-files    insert links to files for direct access
   --max-depth i   ignore anything deeper than i directories [5]
   --max-lines i   only consider the i biggest files [10000]
   --no-diffs      use this if you really do not want diffs
   --save-as file  DEPRECATED, use 'du', see manpage
   --save-state    overwrite a previous '--discard'
   --with-mounts   also look below mountpoints
                  

Changelog

29.08.2007 version 1.4.0

  • Changed package naming syntax
  • modified gt5 to run with plain awk
    (you do not need gawk anymore)
  • added workaround if mktemp is missing

08.02.2007 version 1.3d

  • just some minor fixes in the manpage

24.01.2007 version 1.3c

  • added 'charset' to HTML header to fix UTF-8 encoding problem,
    $LANG is read for charset, use GT5_CHARSET to force another

15.06.2006 version 1.3b

  • fixed quoting in two trap statements which could be used by
    local users to run arbitrary code as the user running gt5

09.05.2006 version 1.3a

  • fixed seconds in 'last check / time ago' - statement
  • fixed hidden feature to download/compile a textbrowser
    (gt5 refused to run without a textbrowser installed)

08.12.2005 version 1.3

  • added diffs: gt5 shows where diskspace has been occupied since last run
  • added colors to show bigger, smaller and new files at the first sight (in case you use a textbrowser that honors a document's coloring)
  • gt5 now can also show du-logs generated with 'du -ak /some/dir'
  • removed support for w3m (see why)
  • wrote a manpage for gt5

17.11.2005 version 1.2f

  • added fallback to use lynx/w3m
    (order: elinks links links2 lynx w3m)

16.11.2005 version 1.2e

  • fixed permissions for gawk/links if build systemwide
  • added --get-elinks and --get-links2, as requested
  • changed the default to ignore mountet filesystems
  • added switch --with-mounts for old behaviour

15.09.2005 version 1.2d

  • added Makefile to be able to install gt5 via toast
  • added LC_ALL=POSIX to override system environment

20.08.2005 version 1.2c

  • improved cutting technics: --cut-at / --max-depth / --max-lines
  • more reliable removing of temporary files trough 'trap'
  • fixed sort order of links-versions within --get-links
  • check for the availability of gawk
  • better escaping of filenames

14.04.2005 version 1.1

  • Fixed a bug triggered by reiserfs where directories can have zero size: If only one subdirectory exists, parent and child have equal size. They were sorted incorrectly, which rendered the parent 'unbrowseable'.
  • Fixed a bug triggered by HTML anchors being caseinsensitive. So directories whose names only differ in case were (of course) indistinguishable.
  • renamed --keep-as to --save-as as I allways mix them up. In fact both switches are accepted.
  • temporary files are now compressed using gzip to minimize diskusage

30.10.2004 version 1.0

  • first public release (gt5 is feature complete)
  • I used it on my own for several weeks now

known bugs:

make uninstall in version 1.2e and 1.2f is buggy: It removes $(PREFIX)/bin instead of $(PREFIX)/bin/$(TARGET), which is /usr/local/bin instead of /usr/local/bin/gt5 by default. A diff-file can be found here. I'm very sorry about that.

Download

The Sources (GPL) are hosted on SourceForge.net
 
gt5 has been packaged for the following distributions:
  • Debian (lenny/sid) via paket manager
  • gentoo via paket manager "portage"
  • Ubuntu (Gutsy/Hardy) via paket manager
  • Fedora (unofficial) by Marcin ZajÄ…czkowski
If your distribution contains gt5 but is not mentioned here, feel free to contact me via this page.

Similar Tools

If you do not like gt5 because it's running in textmode, check these tools:
There is also another textmode tool:
  • ncdu (Linux/BSD/..., MIT-License)

Contact

If you have any question/suggestion, feel free to contact me via this page.

hosted by SourceForge.net Logo