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

From: Paul E Condon (pecondon_at_mesanetworks.net)
Date: 07/31/04

  • Next message: ebe ben: "UPS monitoring cable ditails"
    Date: Sat, 31 Jul 2004 11:48:19 -0600
    To: debian-user@lists.debian.org
    
    

    On Sat, Jul 31, 2004 at 08:47:47AM -0700, Matt Perry wrote:
    > 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{$_}, $_;
    > }
    >

    My one liner is:

    du / | sort -k 1,1nr | most

    The sort gives a listing of du output in descending numerical order,
    so the largest objects are at the top. The very largest object is /,
    since everything else sits under it. If you run this as a user, you
    get a bunch of error messages as it passes over the /proc system. If
    you run this as root, those messages go away, and instead you get a
    bunch of zero length at the end of the list.

    (most is a better less. you can use less if you don't want to install
    most.)

    -- 
    Paul E Condon           
    pecondon@mesanetworks.net
    -- 
    To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    

  • Next message: ebe ben: "UPS monitoring cable ditails"

    Relevant Pages

    • Re: [dapper] x-windows broken again
      ... >>> After the debugging is finished, you might want to change that ... >> a bunch of Pam error messages...and the X keeps crashing script ... > However I think Alsa is borked as well as I get a bunch of error messages ...
      (Ubuntu)
    • Re: sm-mta[386]: My unqualified host name ...
      ... Kiffin Gish writes: ... > and/or I try and send an email using sendmail, I get a bunch of cryptic ... > error messages. ...
      (freebsd-questions)
    • Re: Cant delete files
      ... I found one of the offending files (there are a bunch). ... Singapore Web Hosting ... keep getting error messages for some of the files that say "Cannot ...
      (microsoft.public.windowsxp.general)
    • line numbering
      ... I just used Visual C++ to compile a C code. ... I code a bunch of error messages (mostly syntax errors). ...
      (microsoft.public.dotnet.languages.vc)