#!/usr/local/bin/perl # *********************************************************************** # # * * # # * Copyright (c) 1996-1999 Scott Crevier * # # * All Rights Reserved Worldwide * # # * * # # * This program product material is the property of Scott Crevier. * # # * This program may be used and modified by anyone free of charge, * # # * as long as this copyright notice remains in tact. By using this * # # * code, you agree to indemnify Scott Crevier from any liability * # # * that might arise from its use. * # # * * # # * scott@crevier.org - Scott M. Crevier - www.crevier.org * # # *********************************************************************** # # * smcDiskCheck.pl v2.0 21-Dec-1998 * # # * * # # * This script provides a pretty display of disk space usage in your * # # * current directory. * # # *********************************************************************** # $| = 1; $more = '/usr/bin/more'; $du = '/usr/bin/du'; # *********************************************************************** # # * Get a list of entries in this directory. * # # *********************************************************************** # opendir(DIR,'.') || die "$!"; @entries = grep !/^\.\.?$/, readdir(DIR); close(DIR); # *********************************************************************** # # * Get the disk space usage for each entry, and build a display * # # * string. * # # *********************************************************************** # foreach (sort @entries) { chomp; printf("%-20.20s", $_); print "\b" x 20; $cmd = "$du -s $_"; chomp($string = `$cmd`); ($u,$n) = split(/\t/,$string); $string = sprintf("%8.8s %s", $u /2 , $n); push(@results,"$string\n"); } print ' ' x 20; print "\n"; # *********************************************************************** # # * Sort and display the results. * # # *********************************************************************** # open(M,"|$more"); foreach (sort backwards @results) { print M; } close(M); sub backwards { $b cmp $a; } # *********************************************************************** # # * Done. * # # *********************************************************************** # exit(0);