Jeff Epler's blog

19 February 2012, 16:54 UTC

sorttop: show the biggest values as a program runs


When I am looking for big disk users, I don't care about all the little items. What would be great is to continuously see the biggest items encountered so far.

To this end, I've written a Python program I call 'sorttop'; it continually reads stdin, sorts the first column according to magic (i.e., human numbers like from "du -h" work as expected), and shows the top items read so far. Example usage: du -hx / | python sorttop.py

Update, Feb 20, 2012: Revised the script to work for more terminals; fixes a traceback on the line 'bol = curses.tparm(ti_hpa, 0)' when TERM=screen.

Files currently attached to this page:

sorttop.py3.3kB

read more…

All older entries
Website Copyright © 2004-2024 Jeff Epler