Article View: news.software.nntp
Article #19605Re: Quick way to list how many files in a each subdirectory?
From: Phil Blanchfield
Date: Thu, 24 Jul 1997 00:00
Date: Thu, 24 Jul 1997 00:00
57 lines
2272 bytes
2272 bytes
In article <823ep57gog.fsf@manic.eecs.umich.edu>,
Michael Hucka <hucka@eecs.umich.edu> wrote:
>Maybe someone can save me the time of inventing this wheel: does anyone have
>a utility that will walk down a directory tree and list how many files are in
>each subdirectory? I don't need any other info, just the number of files.
>(I want to go through the news spool and hunt for bloated directories.)
I needed something like this once and I found that the active file provided
enough info for what I wanted. I came up with the following perl script
which takes:
55.420u 1.290s 3:12.85 29.4% 0+462k 8+2io 13pf+0w
to run on a SPARC-10/41
I hope it helps!
#!/usr/local/bin/perl
#
# active-summary - Practically extract and report on the number
# of messages/files in each group.
#
# This is only approximate as the active file only keeps track of the
# lower and upper bounds. Cancellations and articles with explicit
# expire times can leave holes.
$ACTIVE="/usr/lib/news/active"; # the active file
$LOW_WATER=1000; # don't report on groups with < this many
open(ACTIVE,"$ACTIVE") || die "Can't open active file";
while(<ACTIVE>)
{
($group,$max,$min)=split;
$diff=$max-$min;
if( $diff < $LOW_WATER ) { next; }
$group{$group}=$diff;
@sorted_by_narts = sort by_narts keys(%group);
}
foreach $key ( @sorted_by_narts)
{
print "$key $group{$key}\n";
}
sub by_narts
{
$group{$b} <=> $group{$a};
}
--
Phil Blanchfield
The Communications Research Centre 3701 Carling Avenue, Ottawa Ontario CANADA
Internet: Phil.Blanchfield@CRC.DOC.CA Tel: (613) 998-2761 Fax: (613) 998-9648
Technical Details
Message-ID:
<5r8arl$n1@crc-news.doc.ca>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailReferences:
<823ep57gog.fsf@manic.eecs.umich.edu>Show Full Headers
Complete Article Headers
Message-ID: <5r8arl$n1@crc-news.doc.ca> Subject: Re: Quick way to list how many files in a each subdirectory? Date: Thu, 24 Jul 1997 00:00:00 +0000 From: phil@dgbt.doc.ca (Phil Blanchfield) References: <823ep57gog.fsf@manic.eecs.umich.edu> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 258636662 Organization: The Communications Research Centre Newsgroups: news.software.nntp