gt5-1.5.0~20111220+bzr29/ChangeLog0000644000000000000000000001446611674176232014113 0ustar 000000000000002011-12-20 Jari Aalto * gt5.1: (ENVIRONMENT): Document GT5_DEBUG_DIR. * gt5 (GT5_DEBUG_DIR): New variable. (Debug_pipe): New function. (...middle...): Rewrite code to check if du(1) supports --max-depth options. (...everywhere...): Add debug calls to write $HOME/gt5.debug* files if --debug is on. In AWK parts, move variables to "-v" and reduce inline coding. 2010-11-01 Jari Aalto * gt5 - Remove extra 'local' statement. Patch thanks to Stéphane Rosi . - Correct AWK brace placement in "$1 > 0". Patch thanks to Stéphane Rosi . - Remove extra ending semicolons from AWK code. - Rewrite non-POSIX safe logical if operators "-a, -o" with "&&, ||". - Add space after each comma in function calls. 2010-10-11 Jari Aalto * gt5 - Correct following errors; patch thanks to Stéphane Rosi : + Commandline arguments are not working + gt5_substr_after not declared - Minor indentation corrections (by 4) - Minor brace placement adjustments - Minor conditional statement clean ups. Like changing cryptic ||&& combinations into simple if-statements. - Add 'local' keyword to localize variables properly. - Add 'Notes' to the top of file. - Preserve eror codes with 'exit $?', not just 'exit'. 2009-12-09 Jari Aalto * gt5 (DATA): Move after Initialize_tempdir() call so that $TMP gets a value. 2009-12-08 Jari Aalto * gt5 - Move 'trap' call to the "Main:" so that all temporary files are removed. - Initialize() must be run before Initialize_tempdir() - Define AWK variable at the beginning just in case it has value in Replace*() functions. (WhichList): Return status 1 (error), if not found. (Initialize): simplify use of variables $GT5_BROWSER $AWK. Die on error if $AWK is not set. Unset test_in and test_out. Fix linux test by checking /vmlinuz and not grub. (Options): New function. (Which): Return 0 on success or 1. (Grep): Remove variable, use $1 directly. 2009-12-07 Jari Aalto * gt5.1: Document new options --debug and --verbose. Add option --help. Adjust layout to have newlines between heading and options for easier maintenance. * gt5 - Replace all tildes(~) with $HOME. Works better with any shell. - Convert all echo calls to EchoProgress(). - Add new option --verbose - Add new option --debug - option --version now prints plain number, nothing else. Easy for external programs to parse. (Initialize): Add missing slash to '_tmpfile'. (Main:): Call Initialize_tempdir() before Initialize() to define initial value for TMPDIR. (version): Bump version number to 1.4.0.1 (Which): Convert to plain sh. Remove which(1) call. (Requirebin): Die on error if not found. (Verbose): New. (Help): Document new options --debug and --verbose (WhichList): New. (AtExit): New. Remove plain trap command. * g5.1: Bump version number to 1.4.0.1 2009-12-06 Sun Jari Aalto * gt5.1: (TEXTBROWSERS::w3m): clarify version. * Makefile: Add GPL, completely rewrite everything. * gt5 - Add --exclude option (Sourceforge #1360672). - Change /bin/sh to /bin/bash - Rewrite echo -e calls. Options -e is not always available. (REQUIRED_PROGRAMS): New. (SUPPORTED_BROWSERS): New. (Help): Complete rewrite. (Warn): New. (Die): New. (Exist_or_die): 9 New. (Which): New. (Requirebin): New. (Grep): New. (Initialize): New. (Initialize_tempdir): New. (Replace): 9 increase code spacing. Remove gt5_* prefix (Replace_all): increase code spacing. Remove gt5_* prefix (Substr): increase code spacing. Remove gt5_* prefix (Substr_after_all): increase code spacing. Remove gt5_* prefix (Substr_before): increase code spacing. Remove gt5_* prefix 29.08.2007 version 1.4.0 * Changed package naming syntax * modified gt5 to run with plain awk * 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 filename escaping in two trap statements 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 manpage) * wrote a manpage for gt5 17.11.2005 version 1.2f * added fallback to use lynx/w3m (order: elinks links links2 lynx w3m) 15.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 directo- ries 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 gt5-1.5.0~20111220+bzr29/INSTALL0000644000000000000000000000017111674176232013356 0ustar 00000000000000What do you expect? It's a shell-script. Put it wherever you like it (preferable in your PATH), run it and enjoy it. :-) gt5-1.5.0~20111220+bzr29/LICENSE0000644000000000000000000004310311674176232013334 0ustar 00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. gt5-1.5.0~20111220+bzr29/Makefile0000644000000000000000000000343411674176232013772 0ustar 00000000000000# Copyright information # # Copyright (C) 2004-2008 Thomas Sattler # Copyright (C) 2008-2009 Jari Aalto # # License # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . DESTDIR = prefix = /usr exec_prefix = $(prefix) man_prefix = $(prefix)/share PACKAGE = gt5 INSTALL = /usr/bin/install INSTALL_BIN = $(INSTALL) -m 755 INSTALL_DATA = $(INSTALL) -m 644 INSTALL_OBJS = $(PACKAGE) MANDIR1 = $(DESTDIR)$(man_prefix)/man/man1 BINDIR = $(DESTDIR)$(exec_prefix)/bin SBINDIR = $(DESTDIR)$(exec_prefix)/sbin ETCDIR = $(DESTDIR)$/etc/$PACKAGE SHAREDIR = $(DESTDIR)$(prefix)/share/$(PACKAGE) LIBDIR = $(DESTDIR)$(prefix)/lib/$(PACKAGE) INSTALL_OBJS_MAN1 = *.1 all: build build: @echo gt5: nothing to build. clean: -rm -f *[#~] *.\#* *.o *.exe core *.stackdump distclean: clean install-etc: $(INSTALL_BIN) -d $(ETCDIR) $(INSTALL_BIN) $(INSTALL_OBJS_ETC) $(ETCDIR) install-bin: $(INSTALL_BIN) -d $(BINDIR) $(INSTALL_BIN) $(INSTALL_OBJS) $(BINDIR) install-man: $(INSTALL_BIN) -d $(MANDIR1) $(INSTALL_DATA) $(INSTALL_OBJS_MAN1) $(MANDIR1) install: install-bin install-man # End of file gt5-1.5.0~20111220+bzr29/README0000644000000000000000000001340011674176232013204 0ustar 00000000000000 "gt5" or "where has my diskspace gone?" \___________________________________________/ 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 ~~~~~~~~~~ (much more impressive if used with colors!) __________________________________________________________________________ | (p1 of 2) | | gt5 v1.4.0 (pearl:/usr/src/linux): [cut:0.1% depth:5 lines:10000] | | last check was on Thu Dec 7 20:34:17 CET 2005 (i.e. 0d, 00:47:19 ago) | | | | ---------------------------------------------------------------- | | | | ./: [442MB in 40 files or directories] +29MB | | | | 128MB [29.02%] ./drivers/ +21MB | | 63MB [14.35%] ./arch/ +17MB | | 52MB [11.79%] ./shrunken_testfile_1 -39MB | | 42MB [ 9.58%] ./include/ +8.0KB | | 41MB [ 9.29%] ./shrunken_testfile_2 -22MB | | 35MB [ 7.98%] ./fs/ +16MB | | 20MB [ 4.49%] ./net/ +8.5MB | | 19MB [ 4.41%] ./sound/ +4.4MB | | 8.9MB [ 2.03%] ./Documentation/ | | 4.8MB [ 1.09%] ./vmlinux new | | 4.8MB [ 1.09%] ./.tmp_vmlinux2 new | | 4.6MB [ 1.05%] ./.tmp_vmlinux1 new | | 2.9MB [ 0.65%] ./kernel/ +1.5MB | | 2.1MB [ 0.48%] ./crypto/ +1.5MB | | | |http://gt5.sourceforge.net/sample.html#914________________________________| 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 general | meaning in gt5 | ====================================================================== | Cursor Left | go back | go one directory up | |----------------|-------------------------|-------------------------| | Cursor Right | follow link | open selected directory | |----------------|-------------------------|-------------------------| | Cursor Up/Down | go to link above/below | move Cursor Up/Down | |----------------|-------------------------|-------------------------| | Insert/Delete | scroll page up/down | scroll page up/down | |----------------|-------------------------|-------------------------| | Ctrl-C | quit textbrowser | quit 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 Download ~~~~~~~~ Files are hosted on SourceForge.net: (gt5 is released under GPL.) http://sourceforge.net/project/showfiles.php?group_id=122114 Contact ~~~~~~~ If you have any question/suggestion, feel free to contact me via http://sourceforge.net/users/tsattler/ gt5-1.5.0~20111220+bzr29/gt50000755000000000000000000003723211674176232012762 0ustar 00000000000000#!/bin/bash # # Copyright information # # Copyright (C) 2004-2008 Thomas Sattler # Copyright (C) 2008-2011 Jari Aalto # # License # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Description # # Call program with -h. See http://gt5.sf.net/browsers.html # # Notes # # The bash features used are as follows: # # RANDOM # local VAR version=1.4.0.3 GT5_DEBUG_DIR=${GT5_DEBUG_DIR:-$HOME} # HTML-colors: --------------------------------------------------------------- BG=black #background DIR=blue #dir-links FILE=cyan #file-links HR=olive #seperators LAST=green #last check was on ... LAST2=magenta # ... date_string ... LAST3=magenta # ... time since LESS=lime #smaller files MORE=red #bigger files NEW=yellow #new files PC=darkred #percent SIZE=purple #sizes SUM=white #dir-size TEXT=grey #plaintext REQUIRED_PROGRAMS="\ cat \ cp \ date \ du \ grep \ gzip \ head \ hostname \ ls \ mkdir \ mv \ rm \ sed \ sort \ tac \ tee \ touch \ " SUPPORTED_BROWSERS="\ links \ links2 \ elinks \ lynx \ w3m \ " AWK=awk # Online help: ---------------------------------------------------------------- Help () { echo "\ SYNOPSIS $0 [ dir | file | dir file | file file2 ] [options] DESCRIPTION Display disk usage statistics using text based web browser. ARGUMENTS dir The directory you want to check for space used file/file2 Existing du-logs (du -akx \$DIR #gz/bz2/plain) OPTIONS --cut-at float Don't show files below 'float'% of its parent, Default is $CUT_AT, use values between 0.01 and 30 --debug Turn on debug mode. Do not run browser. --diff-dir DIR Use DIR to store diffs between runs [$(Replace $DDIR $HOME/ ~/)] --discard Do not save this one for diffs, discard it --exclude s Hand s over to du to exclude its size --link-files Insert links to files for direct access --max-depth i Ignore anything deeper than i directories [$MAX_DEPTH] --max-lines i Only consider the i biggest files [$ML] --megabytes Expect du-logs to be run as 'du -amx' --no-diffs Use this if you really do not want diffs --save-state Overwrite a previous '--discard' --verbose Display verbose messages. --with-mounts Also look below mountpoints" exit 0 } # Support functions: ------------------------------------------------------------ Warn () { echo "$*" >&2 } Die () { Warn "$*" >&2 exit 1 } Debug_pipe () { if [ "$DEBUG" ]; then tee $GT5_DEBUG_DIR/gt5.debug$1.log else cat fi } Verbose () { if [ "$VERBOSE" ]; then Warn "$*" fi } Exist_or_die () { [ -s "$1" ] && continue # Non zero? [ -d "$1" ] && continue shift Die "$@" } Which () {( # Run in a subshell to save "--" positional arguments. bin="$1" case "$bin" in /* | ./*) if [ -x "$bin" ]; then echo "$bin" return 0 fi ;; esac IFS=: set -- $PATH for path in "$@" do path="$path/$bin" if [ -x "$path" ]; then echo "$path" return 0 fi done return 1 )} WhichList () { local i for i in "$@" do if Which "$i" ; then return 0 fi done return 1 } Requirebin () { local i for i in "$@" do if ! Which "$i" > /dev/null; then Die "ERROR: Not any found in PATH: $i" fi done } Grep () { # Return only $? status code: matched or not echo "$*" | egrep -e "$1" > /dev/null 2>&1 } Initialize () { if [ -e /vmlinuz ]; then # The program tests are not needed under Linux. Faster startup : else Requirebin $REQUIRED_PROGRAMS fi Grep '/$' "$_tmpdir" || _tmpdir="$_tmpdir/" # verify trailing slash local _tmpdir _tmpdir=${TMPDIR:-/tmp} local _tmpfile _tmpfile=$_tmpdir/$$.tmp WhichList $GT5_BROWSER $SUPPORTED_BROWSERS > $_tmpfile BROWSER=$(cat $_tmpfile) if [ ! "$BROWSER" ]; then Die "ERROR: Can't set browser from \$GT5_BROWSER or list: $SUPPORTED_BROWSERS" fi WhichList $GT5_AWK gawk awk > $_tmpfile AWK=$(cat $_tmpfile) if [ ! "$AWK" ]; then Die "ERROR: Can't set awk from \$GT5_AWK or list gawk awk" fi # Does sort work? (broken in busybox 1.4.[01]) # No 'echo -e' in all /bin/sh versions like dash local test_in test_in="$(echo 1 b; echo 2 a)" local test_out test_out="$(echo "$test_in" | sort -k1 -k2)" if [ "$test_in" != "$test_out" ] ; then Die "ERROR: sort options -k1 -k2 do not work correctly." fi unset test_in test_out rm -f $_tmpfile unset _tmpdir _tmpfile } Initialize_tempdir () { # Set global variable TMP for temporary directory if [ ! "$TMPDIR" ]; then TMPDIR=/tmp fi if [ ! -w "$TMPDIR" ]; then Dir "ERROR: TMPDIR not setcan't write to \$TMPDIR $TMPDIR" fi local dir dir="${TMPDIR:-/tmp}/$(Substr_after_all "$0" /).$(date '+%Y%m%d-%H%M%S')" dir="$(Replace_all "$dir" '[^a-zA-Z0-9/.-]' _)" # there may be systems without mktemp unset TMP if Which mktemp > /dev/null ; then TMP=$(mktemp -d -q "$dir.XXXXXXXX") else dir="$dir.$$.$RANDOM" mkdir "$dir" || exit $? TMP=$dir fi if [ ! "$TMP" ]; then Die "ERROR: error creating a temporary directory" fi unset dir } At_exit () { # From Initialize() rm -f ${TMPDIR:-/tmp}/$$* # From Initialize_tempdir() if [ "$TMP" ]; then if [ "$DEBUG" ]; then echo "DEBUG: not removed $TMP" else rm -rf "$TMP" fi fi # From end of file, generated files if [ "$ESCAPED_GS" ]; then rm -rf "$ESCAPED_GS" fi } # Functions: ------------------------------------------------------------- Replace() { # replace: ${s/a/b}, args: string from to echo "$1" | "$AWK" '{ sub(a,b); print }' a="$2" b="$3" } Replace_all() { # replace: ${s//a/b}, args: string from to echo "$1" | "$AWK" '{ gsub(a,b); print}' a="$2" b="$3" } Substr() { # replace: ${s:0:1}, args: string start [end] echo "$1" | "$AWK" -F"\n" "{ print( substr(\$1,$2${3:+,$3})) }" } Substr_after_all() { # replace: ${s##*/}, args: string return_s_after echo "$1" | "$AWK" '{ sub(s,""); print} ' s=".*$2" } Substr_before() { # replace: ${s%/*}, args: string return_s_before echo "$1" | "$AWK" ' { for ( i = length($0); i; i-- ) { if ( index(substr($0, i), s) ) { print( substr($0, 1, i -1) ) exit } } print }' s="$2" } # Parse Options: -------------------------------------------------------------- Options () { while [ "$1" ] do case "$1" in --cut-at) case "$2" in [0-9]|[0-9].[0-9]|[0-9].[0-9][1-9]) ;; [1-3][0-9]|[1-3][0-9].[0-9]|[1-3][0-9].[0-9][1-9]) ;; *) echo "bad cut-at-arg \"$2\", use values between 0.01 and 30" exit 1 ;; esac CUT_AT=$2 shift ;; --debug) DEBUG=debug SAVE_DU=save_du ;; --diff-dir) DDIR="$2" shift ;; --discard) unset SAVE_DU ;; --exclude) [ "$2" ] || Help EXCLUDE="$EXCLUDE --exclude $2" shift ;; --link-files) LINK_FILES=true ;; --max-depth) case "$2" in [0-9]|[1-9][0-9]) ;; *) echo "bad max-depth-arg \"$2\", valid is 0-99" exit 1 ;; esac MAX_DEPTH=$2 shift ;; --max-lines) case "$2" in [1-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9]) ;; *) echo "bad max-lines-arg \"$2\", valid is 10000-999999" exit 1 ;; esac ML=$2 shift ;; --megabytes) UNIT=M ;; --no-diffs) DIFFS=0 unset SAVE_DU ;; --save-du-as) SAVE_DU_AS="$2" shift ;; --save-state) SAVE_DU=1 ;; --verbose) VERBOSE=verbose ;; --version) echo $version exit 0 ;; --with-mounts) unset X ;; *) # Directories and files to show unset VALID if [ -d "$1" ] ; then [ "$CD$F2" ] && Help cd "$1" || exit $? cd "$OLDPWD" CD="$OLDPWD" VALID=1 fi if [ -f "$1" ] ; then H="$(Substr "$1" 1 1)" [ "$F2" ] && Help [ "$F1" -a "$CD" ] && Help if [ ! -r "$1" ] ; then Die "ERROR: cannot read \"$1\"" fi [ "$H" != "~" -a "$H" != "/" ] && H="$PWD/" || unset H [ "$F1" ] && F2="$H$1" || F1="$H$1" VALID=1 fi [ "$VALID" ] || Help ;; esac shift done } # Main: -------------------------------------------------------------- umask 077 unset BIN CD CONFIGURE_OPTS CUT DATE F1 F2 LINK_FILES SAVE_DU_AS SINCE unset VERBOSE DEBUG trap At_exit 0 1 3 15 Initialize Initialize_tempdir Options "$@" SPACE="_escaped_${RANDOM}_space_" TAB="_escaped_${RANDOM}_tab_" DATA=$TMP/gt5.html DDIR=$HOME/.gt5-diffs CUT_AT="0.1" MAX_DEPTH=5 SAVE_DU=1 ML=10000 DIFFS=1 UNIT=K X=x # Treat options: ------------------------------------------------------ [ "$CD" ] && cd "$OLDPWD" if [ "$SAVE_DU_AS" ] ; then du -ak$X 2> /dev/null | grep -v ^0 | gzip > "$SAVE_DU_AS-$(date +%y%m%d-%H%M).gz" exit fi GENERIC_STORE=$(Replace_all "$PWD" "_" "__").gz GENERIC_STORE="$DDIR/$(Replace_all "$GENERIC_STORE" "/" "_,")" [ -d "$DDIR" ] || mkdir "$DDIR" || exit $? [ "$F1" ] && unset SAVE_DU || { [ "$CD" ] || CD=$PWD unset H F1="$(Replace_all "$CD" "_" "__")" F1="$DDIR/$(Replace_all "$F1" "/" "_,")" while [ ! -f "$F1.gz" ] && [ "$F1" != "$DDIR/" ] do H="/$(Substr_after_all "$F1" "_,")$H" F1=$(Substr_before "$F1" "_,") done #FIX: no '==' in dash [ "$F1" = "$DDIR/" ] && F1="$DDIR/_," [ -f "$F1.gz" ] && { CUT="$H"; F1="$F1.gz"; } || unset F1 } if [ "$F1" ]; then DATE=$(date -r "$F1") SINCE=$(date -r "$F1" +%s) fi if [ "$CD" ] ; then P="${HOSTNAME:-$(hostname)}:$PWD" [ "$P" ] || P="file: $F1" fi if [ -z "$CD$F2" ] || [ -z "$F1" ]; then DIFFS=0 fi [ "$CD" ] || unset LINK_FILES SAVE_DU # Can du handle depths? if du --help 2>&1 | grep max-depth > /dev/null 2>&1 then DEPTH="--max-depth=$((MAX_DEPTH + 1))" fi { ID=0 if [ "$CD" ]; then Verbose "processing \"$(Replace "$PWD" "$HOME/" "~/")\", please be patient ... " du -ak$X $DEPTH $EXCLUDE 2> /dev/null | grep -v ^0 | tee "$TMP/this" | sed "s,^,$ID ," ID=$((ID + 1)) Verbose "done" fi for f in "$F1" "$F2" do [ -f "$f" ] || continue case "$f" in *gz) CAT="gzip -cd" ;; *bz2) CAT="bzip2 -cd" ;; *) CAT=cat ;; esac if [ "$f" ] && [ $ID -le $DIFFS ] ; then Verbose "processing \"$(Replace "$f" "$HOME/" "~/")\" ... " $CAT "$f" | sort -k1nr -k2 | "$AWK" ' NR == 1 { sub(/\/$/,"") P = " "$2"'"$CUT"'" } $1 && /'"$(Replace_all "$CUT" "/" "\\\/")"'/ { sub(/^/,"'$ID' ") sub(P," .") sub(/\/$/,"") print }' ID=$((ID+1)) Verbose "done" fi done Verbose "Generating HTML ... " } | Debug_pipe 1a | sed 's, ,'"$SPACE"',g; s,'"$SPACE"', ,; s, ,'"$TAB"',g; s,'"$TAB"', ,' | Debug_pipe 1b | # gt5's magic starts here: sort -k3 -k1,1nr | Debug_pipe 1c | "$AWK" ' { if ( ! $1 ) { printf("%s %s %s\n", $2, (on == $3 ? os : -1), $3) } else { os = $2 on = $3 } on = $3 }' | Debug_pipe 2a | sort -k1,1nr -k3 | Debug_pipe 2b | "$AWK" -v ML="$ML" ' NR > ML { exit } { if ( NR == 1 ) { printf("%s %s\n", $0, $0) } size[me] = $1 osize[me] = $2 me = $3 e = 0 while ( i = index( substr(me, e + 1), "/") ) e += i; if (e) { p = substr(me, 1, e - 1) printf("%s %s %s %s\n", size[p], osize[p], p, $0) } } ' | Debug_pipe 3a | sort -k1,1n -k3,3r -k4,4n | Debug_pipe 3b | "$AWK" -v unit=$UNIT -v DATE=$(date +%s) -v SINCE=${SINCE:-0} ' BEGIN { H = DATE - SINCE print "" s = H%60 H /= 60 m = H%60 H /= 60 h = H%24 d = H/24 timespan = sprintf("%id, %02i:%02i:%02i", d, h, m, s) } function i2h(i) { E = unit i += 0 # Force to number if ( unit == "K" && i > 999) { i /= 1024 E = "M" } if ( i > 999 ) { i /= 1024 E = "G" } if ( i > 999 ) { i /= 1024 E = "T" } if ( i < 9.95 ) return sprintf("%.1f%cB", i, E) else return sprintf("%.0f%cB", i, E) } function directory (p, ps, pos, pf) { if ( !p ) return; # No parent on first call printf "\n%s/: [%s",p,i2h(ps) printf " in "children[p]" files or directories] " if ( '$DIFFS' ) { if ( pos == -1 ) { printf "new"; } else { if ( ps < pos ) printf "-%s", i2h(pos - ps) if ( ps > pos ) printf "+%s", i2h(ps - pos) } } print "\n
" if ( '$DIFFS' && "'"$F2"'"=="" ) { printf " last check was on '"$DATE"' (i.e. "timespan" ago)\n" } printf "gt5 '"$version ($P)"': [cut:" print '$CUT_AT'"% depth:"'$MAX_DEPTH'" lines:"'$ML'"]" if ( pf ) { for ( i = 0; i < 16; ++i ) print "\n\n\n\n\n\n\n\n" } } $1 > 0 { # Division by zero ... if ( op != $3 ) directory(op, ops, opos, 1) ops = $1 opos = $2 op = $3 pz = 100 * $4 / ops e = 0 while ( j = index( substr($6, e + 1), "/") ) e += j; s = substr($6, e + 1) children[$3]++ if ( children[$6] ) { s = ""s"/" } else if ( "'"$LINK_FILES"'" ) { h = ""s"" } if ( pz >= '"$CUT_AT"' && $6 != "." ) { printf "%6s ",i2h($4) printf "[%5.2f%%] ./%s ", pz, s if ( '$DIFFS' ) { if ( $5 == -1 ) printf "new" else { if ( $4 < $5) printf "-%s", i2h( $5 - $4) if ( $4 > $5) printf "+%s", i2h( $4 - $5) } } printf "\n" } } END { directory(op, ops, opos) if ( !x ) print " directory seems to be empty\n\n\ngt5 v'"$version ($P)"'" printf "
"
    }
' |
  Debug_pipe 4a |
  sed 's,'"$SPACE"', ,g;s,'"$TAB"',   ,g' |
  Debug_pipe 4b |
  head -c 16m |
  Debug_pipe 4c |
  tac |
  Debug_pipe 4d \
  > $DATA #max 16MB HTML

Verbose "Generating HTML ... done (size: $(Substr_before "$(ls -sh "$DATA")" " "))"

if [ "$SAVE_DU" ] ; then

  touch "$GENERIC_STORE.$$.tmp" || exit $?

  gzip < "$TMP/this" > "$GENERIC_STORE.$$.tmp" &&
    mv "$GENERIC_STORE.$$.tmp" "$GENERIC_STORE"

  ESCAPED_GS=$(Replace_all "$GENERIC_STORE.$$.tmp" "\"" "\\\"")
fi

Verbose "Starting browser ($(Replace "$BROWSER" "$HOME/" "~/")) ... "

cp -l $DATA $HOME/.gt5.html 2> /dev/null || cp $DATA $HOME/.gt5.html || exit $?

${DEBUG+echo} $BROWSER $DATA

# End of file
gt5-1.5.0~20111220+bzr29/gt5.10000644000000000000000000001011711674176232013107 0ustar  00000000000000.TH gt5 1 "July 2009" "gt5 v1.4.0.1"

.SH NAME
gt5 \- a diff\-capable 'du\-browser'

.SH SYNOPSIS
.B gt5
[ dir | file | dir file | file file2 ] [options]

.SH DESCRIPTION
.B gt5
reads the output of
.BR du ,
compares it with a du\-log saved by the last run,
converts it into HTML and opens the resulting file with a
.BR textbrowser .

If files are given on the commandline they are expected to be
(optionally
.IR gzip / bzip2 \-compressed)
logfiles of
.BR "du \-akx /some/dir" .
It is up to you to take care that the given directories/files represent
the same directory.
.I gt5
will show lots of new files if you don't. ;\-)

.SH OPTIONS

.IP "\-\-cut\-at float"
Files and directories that are below
.I float
percent of their parents are not shown.  Default is
.IR 0.1 ,
gt5 will accept values between 0.01 and 30.

.IP \-\-debug
Turn on debug. Generate HTML files and do not run browser.

.IP "\-\-diff\-dir directory"
Use
.I directory
instead of
.I ~/.gt5\-diffs/
to read/store du\-logs.
This switch is ignored if gt5 is only used with files.

.IP \-\-discard
Do not save the current state, in other words: be able to diff against the old
state again.  This feature is disabled if gt5 is only used with files.

.IP \-\-help
Display brief help.

.IP \-\-link\-files
Also insert links to files to access them from within gt5.  This can be very
handy if your browser is configured to handle the files MIME\-type correctly.
This feature is disabled if gt5 is only used with files.

.IP "\-\-max\-depth int"
Do not show anything below a depth of
.I int
directories. Default is
.IR 5
(also see
.B BUGS
below).

.IP "\-\-max\-lines int"
Only consider the
.I int
biggest files and directories within the output of
.IR du .

.IP \-\-no\-diffs
Use this if you are not interested in the history of the directories processed,
for example in /tmp.

.IP "\-\-save\-as file"
DEPRECATED, use
.B du \-akx
or
.B du \-ak
(see
.BR \-\-with\-mounts ),
save the output to a file and run gt5 against one (ore two) of these files
later.

.IP \-\-save\-state
Force saving current state, overwriting a previous
.IR \-\-discard .
(Some people seem to have gt5 aliased to
.IR "'gt5 \-\-discard'" .)

.IP \-\-verbose
Display messages.

.IP \-\-with\-mounts
By default gt5 calls
.B du
with
.B \-akx
to ignore mounted filesystems. Use this to inspect mounted partitions too, i.e. call
.B du
with
.B \-ak

.SH HELPERS
If
.I gawk
or a
.I textbrowser
are missing and you want to install them into
.IR "~/bin " "(or " "/usr/local/bin " "if you have write access there), " gt5
comes with the following helpers:

.IP \-\-get\-gawk
Download, compile and install a copy of
.IR gawk .

.IP \-\-get\-links
Download, compile and install a copy of
.IR links .

.IP \-\-get\-links2
Download, compile and install a copy of
.IR links2 .

.IP \-\-get\-elinks
Download, compile and install a copy of
.IR elinks .

.SH TEXTBROWSERS
It is recommended to use
.IR "links " "with " gt5 .
Other textbrowsers are also possible but there are several
good reasons why links is given priority over the others:

.IP elinks:
links is
.I much
faster on startup/exit

.IP lynx:
does not honor a documents
.I coloring

.IP netrik:
no colors,
.I unfavourable cursor navigation

.IP retawq:
no colors,
.I can't
handle \-tags

.IP w3m:
.I Version 0.5.2 and later are known to work. Older versions experienced unfavourable
handling of \-tag,
.I unfavourable cursor navigation
and no colors
.PP
Only
.IR links / links2 ", " "elinks " "and " lynx
are now considered usable (and also chosen in that order). See
.BR ENVIRONMENT / GT5_BROWSER
below.

.SH FILES
.I ~/.gt5.html
.RS
contains a copy of the last run
.RE
.I ~/.gt5\-diffs/
.RS
compressed du\-logs are stored here

.SH ENVIRONMENT

.IP GT5_BROWSER
force using a (specific) textbrowser

.IP GT5_CHARSET
force using a (specific) charset for HTML header instead of using
.I $LANG

.IP GT5_DEBUG_DIR
Directory where to write gt5.debug* data if --debug option is set.

.SH BUGS
Directories at depth
.B max\-depth
are not browsable and so look like files.

.SH AUTHOR
Thomas Sattler 

.SH "SEE ALSO"
.BR du (1),
.BR links (1),
.BR elinks (1),
.BR lynx (1)