Here is the actual code and output, I am allready using system, but was
hoping for a perl only solution.
#!/usr/bin/perl -w
#
#
open(PASSWD, "/etc/passwd");
while (<PASSWD>) {
@fields = split /:/;
if ($fields[2] >= 500) {
chdir $fields[5];
$disk_space = system("du -s .");
write;
}
}
close(PASSWD);
format STDOUT_TOP=
Disk Usage Stats
===============================================================================
Name User Name Home directory Disk usage
.
format STDOUT=
@<<<<<<<<<<<<<<<<< @<<<<<<<< @<<<<<<<<<<<<<< @####.## Mb
$fields[4], $fields[0], $fields[5], $disk_space
.
And this is what the output looks like:
421676 . <--- This should be under the disk usage column
Disk Usage Stats
===============================================================================
Name User Name Home directory Disk usage
Paul Fontenot paul /home/paul 0.00 Mb
18132 . <--- So should this
Heather Fontenot heather /home/heather 0.00 Mb
Thanks for any formatting help.
-Paul
On Friday 13 April 2001 16:56, you wrote:
> At 04:02 PM 4/13/01 -0700, Paul Fontenot wrote:
> >Hello,
> > How can I get a summary of the file sizes in a directory with
> > perl? Like a
> >"du -s ." ?
>
> du walks the directory tree summing all the components in subdirectories;
> Perl code to do that is going to be more than a few lines. Any reason you
> can't do
>
> system("du -s .")
>
> ? Otherwise you've got some work ahead of you with File::Find, since I
> can't see any module on CPAN for this.
> --
> Peter Scott
> Pacific Systems Design Technologies
--
4:59pm up 7:53, 3 users, load average: 1.66, 1.57, 1.73