RE: Directory Size
- From: jkipp5@xxxxxxxxxxx (Jim)
- Date: Sun, 28 Aug 2005 17:34:07 -0400
> -----Original Message-----
> From: Nick [mailto:lists@xxxxxxxxxxx]
> Sent: Sunday, August 28, 2005 1:26 PM
> To: Perl Beginners
> Subject: Directory Size
>
> Hi All,
>
> Is there a way to get an entire directory and all
> sub-files/folders size in Perl? Basicly, I need the Perl
> version of "du -s".
>
> I've currently done it with stat but this only gives a
> directory size not taking into consideration everything inside it.
>
> Nick
>
Try this:
use File::Find;
my $dir = $ARGV[0];
my $size;
find( sub { -f and ( $size += -s _ ) }, $dir );
.
- References:
- Directory Size
- From: Nick
- Directory Size
- Prev by Date: File downloads when I try mod_perl redirect
- Next by Date: alarm and pcap::loop
- Previous by thread: Directory Size
- Next by thread: Re: Directory Size
- Index(es):
Relevant Pages
|
|