A guy I know wrote a patch to `df' that gives it a histogram switch.
Here's the tested diff against `fileutils-4.0l-5'.
2000-02-01 W. Reilly Cooley, Esq. <wcooley@nakedape.cc>
* doc/fileutils.texi: Document `--histogram' switch.
* src/df.c (enum): Add HISTOGRAM_OPTION.
(long_options): Add `histogram'.
(show_dev): Support `show_histogram'.
(usage): Display `--histogram' option.
(main): Add HISTOGRAM_OPTION to switch.
--- doc/fileutils.texi.orig Wed Dec 15 00:56:55 1999
+++ doc/fileutils.texi Tue Feb 1 15:22:25 2000
@@ -2924,6 +2924,11 @@
type ``ignore'' or ``auto'', supported by some operating systems, are
only included if this option is specified.
+@itemx --histogram
+@opindex --histogram
+@cindex draw a histogram
+Draw a histogram for each filesystem.
+
@item -h
@itemx --human-readable
@opindex -h
--- src/df.c.orig Thu Dec 9 07:42:04 1999
+++ src/df.c Tue Feb 1 16:07:11 2000
@@ -17,7 +17,8 @@
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>.
--human-readable and --megabyte options added by lm@sgi.com.
- --si and large file support added by eggert@twinsun.com. */
+ --si and large file support added by eggert@twinsun.com.
+ --histogram added by wcooley@nakedape.cc. */
#include <config.h>
#if HAVE_INTTYPES_H
@@ -75,6 +76,9 @@
SunOs4.1.3, for one. It is *not* necessary on Linux. */
static int require_sync = 0;
+/* If nonzero, print a histogram for each filesystem. */
+static int show_histogram;
+
/* Nonzero if errors have occurred. */
static int exit_status;
@@ -116,7 +120,8 @@
{
SYNC_OPTION = CHAR_MAX + 1,
NO_SYNC_OPTION,
- BLOCK_SIZE_OPTION
+ BLOCK_SIZE_OPTION,
+ HISTOGRAM_OPTION
};
static struct option const long_options[] =
@@ -135,6 +140,7 @@
{"no-sync", no_argument, NULL, NO_SYNC_OPTION},
{"type", required_argument, NULL, 't'},
{"exclude-type", required_argument, NULL, 'x'},
+ {"histogram", no_argument, NULL, HISTOGRAM_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0}
@@ -397,6 +403,25 @@
printf (" %s", mount_point);
}
putchar ('\n');
+
+ if (show_histogram)
+ {
+ int i;
+ printf ("0%% |") ;
+ /* Use 20 chars */
+ for ( i = 1 ; i <= 50 ; i++)
+ {
+ double blocks_percent_used = posix_format
+ ? ceil_percent (used, nonroot_total)
+ : used * 100.0 / nonroot_total;
+ if (blocks_percent_used - (i*2) >= 0)
+ putchar ('#') ;
+ else
+ putchar (' ') ;
+ }
+ printf ("| 100%%\n") ;
+ }
+
}
/* Identify the directory, if any, that device
@@ -638,6 +663,7 @@
\n\
-a, --all include filesystems having 0 blocks\n\
--block-size=SIZE use SIZE-byte blocks\n\
+ --histogram show histogram of percentage\n\
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)\n\
-H, --si likewise, but use powers of 1000 not 1024\n\
-i, --inodes list inode information instead of block usage\n\
@@ -726,6 +752,10 @@
case BLOCK_SIZE_OPTION:
human_block_size (optarg, 1, &output_block_size);
+ break;
+
+ case HISTOGRAM_OPTION:
+ show_histogram = 1 ;
break;
case 'F':