Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: size of directory

by mikeirw (Pilgrim)
on Oct 10, 2002 at 07:08 UTC ( #204109=note: print w/replies, xml ) Need Help??


in reply to size of directory

If you're wanting to sum the sizes of all files within a directory, this should do it:

my $dir = '/path/to/dir'; my $dir_size = 0; my $file; opendir DIR, $dir or die "Unable to open $dir: $!\n"; $dir_size += -s "$dir/$file" while defined( $file = readdir DIR ); closedir DIR; print $dir_size;

This does not descend into subdirectories, though.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://204109]
help
Chatterbox?
[Corion]: Meh, stupid people are associated with every president
[Corion]: (or presidential candidate)
[Corion]: And if you only have two candidates, you can expect some of the stupid people to make the "right" choice by chance ;)
[erix]: I think it's a little worse this time :)
[Discipulus]: yes; even broken clock show the right time twice a day

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2017-01-24 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (203 votes). Check out past polls.