Re: script/app to compile statistics about disk usage?

From: Matt Perry (matt_at_primefactor.com)
Date: 07/31/04

  • Next message: Silvan: "Re: How to Move from 1 drive to another?"
    Date: Sat, 31 Jul 2004 08:47:47 -0700 (PDT)
    To: debian-user@lists.debian.org
    
    

    On Fri, 30 Jul 2004, Silvan wrote:

    > cooked up. What I want to do is look at my disks and gather statistics about
    > what is eating the most space. Where the biggest files are, which
    > directories are the largest, etc.

    What I do to see large directories is just 'du -sh *' starting at root and
    then drilling down from there. If you want to see what the largest files
    are, you can use this Perl script that Randal Schwartz wrote:

    #!/usr/bin/perl
    #
    # Usage: bigfiles <dir> [dir ...]
    #
    # Abstract: This script reports the top 20 largest files in one or
    # more specified directories, including subdirectories.
    #
    # By: Randal Schwartz <merlyn@stonehenge.com>
    # From the article at
    # http://www.stonehenge.com/merlyn/UnixReview/col16.html

    if ($#ARGV lt 0) {
      $0 =~ s#.*/##;
      print("Usage: $0 <dir> [dir ...]\n");
      exit 1;
    }

    use File::Find;
    find (sub {
            $size{$File::Find::name} =
              -s if -f;
          }, @ARGV);
    @sorted = sort {
      $size{$b} <=> $size{$a}
    } keys %size;
    splice @sorted, 20 if @sorted > 20;
    foreach (@sorted) {
      printf "%10d %s\n", $size{$_}, $_;
    }

    -- 
    To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    

  • Next message: Silvan: "Re: How to Move from 1 drive to another?"