Ask a Question related to PERL Beginners, Design and Development.
-
Motherofperls@aol.com #1
Getting the total size of a directory
I'm running out of web space and want to write a script that tell me the size
of certain directories so I can see where the hog is.
Can anyone give me some quick code?
Motherofperls@aol.com Guest
-
Directory Size
Greetings learned PHP(eople); Is there a way to calculate the size of directory in PHP ? I searched php.net and only found ways of opening... -
Setting total db size to a variable.
I have a question in regards to finding the total db size and setting it to a variable. How would I go about this? -
Cast Members Size Vs. Total Movie Size
What ultimately worked for me was to choose "Link to External File" in the media drop-down box within the importing dialog box when importing files.... -
[PHP] Setting total db size to a variable.
Jason Martyn <in3words@telus.net> wrote: This is rather vague in several aspects. Please expand on your question with more details, otherwise it... -
Getting the total size of files matching a pattern?
Math55 wrote: 1. open the directory you're interested in (perldoc -f opendir) 2. loop through all files in the open directory... (perldoc... -
Rus Foster #2
Re: Getting the total size of a directory
On Sun, 4 Jan 2004 [email]Motherofperls@aol.com[/email] wrote:
A shell script might be even faster with du -s /tmp | sort -n> I'm running out of web space and want to write a script that tell me the size
> of certain directories so I can see where the hog is.
>
> Can anyone give me some quick code?
Rus
--
e: [email]support@vpscolo.com[/email]
t: 1-888-327-6330
[url]www.jvds.com[/url] - Root on your own box
[url]www.vpscolo.com[/url] - Your next hosting company
Rus Foster Guest
-
Tim Johnson #3
RE: Getting the total size of a directory
I think there was a very recent thread on this, but here's one way using File::Find, taking a little from a result I found by arching Google:
##################################
use File::Find;
use strict;
my $dir = $ARGV[0];
my $size;
find(sub{ -f and ( $size += -s ) }, $dir );
$size = sprintf("%.02f",$size / 1024 / 1024);
print "Directory '$dir' contains $size MB\n";
##################################
-----Original Message-----
From: [email]Motherofperls@aol.com[/email] [mailto:Motherofperls@aol.com]
Sent: Sun 1/4/2004 6:10 PM
To: [email]beginners@perl.org[/email]
Cc:
Subject: Getting the total size of a directory
I'm running out of web space and want to write a script that tell me the size
of certain directories so I can see where the hog is.
Can anyone give me some quick code?
Tim Johnson Guest
-
Randal L. Schwartz #4
Re: Getting the total size of a directory
>>>>> "Tim" == Tim Johnson <tjohnson@sandisk.com> writes:
Tim> find(sub{ -f and ( $size += -s ) }, $dir );
Beware that -s has only a rough correlation with the actual disk a
file takes. You want (stat)[12] for that. The -s number will be far
too huge for holey files (blocks aren't allocated), and a little too
low for large files (indirect blocks).
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Randal L. Schwartz Guest
-
MacWarrior #5
Getting the total size of a directory
I got my problem solved. Thanks for this comment Tim! You're brilliant!
-MacWarrior-
-----------------------------------------------------------------------------------
I think there was a very recent thread on this, but here's one way using File::Find, taking a little from a result I found by arching Google:
##################################
use File::Find;
use strict;
my $dir = $ARGV[0];
my $size;
find(sub{ -f and ( $size += -s ) }, $dir );
$size = sprintf("%.02f",$size / 1024 / 1024);
print "Directory '$dir' contains $size MB\n";
##################################
-----Original Message-----
From: [email]Motherofperls@aol.com[/email] [mailto:Motherofperls@aol.com]
Sent: Sun 1/4/2004 6:10 PM
To: [email]beginners@perl.org[/email]
Cc:
Subject: Getting the total size of a directory
I'm running out of web space and want to write a script that tell me the size
of certain directories so I can see where the hog is.
Can anyone give me some quick code?MacWarrior Guest



Reply With Quote

