in reply to Unix disk space reports
This seems much too complicated for my liking.
I really don't like the way it needs to create a temporary file, and that it writes it output out to a fixed file, rather than STDOUT, thus letting me redirect it, or play with it in some other way. I'd go for something more along the lines of:
Then I'd call it as: perl ~/dfk hosts/* > reportuse strict; my %space; while (<>) { next unless m#^/#; next if m#^/proc#; next unless m#^[^ ]* *([^ ]*) *[^ ]* *([^ ]*) *[^ ]*#; $space{$ARGV}{total} += $1; $space{$ARGV}{free} += $2; } foreach my $host (sort keys %space) { printf "%s: %dk free, out of %dk, (%.2f%%)\n", $host, $space{$host}{free}, $space{$host}{total}, $space{$host}{free} / $space{$host}{total} * 100; }
Playing with the format of the output is then trivial.
If you really want to be able to view the intermediate 'space' file, then you could add a command line parameter for it (including the name of the output file?).
Tony
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Unix disk space reports
by halxd2 (Monk) on Jan 02, 2001 at 19:43 UTC | |
by Anonymous Monk on Feb 10, 2009 at 09:31 UTC | |
by Corion (Patriarch) on Feb 10, 2009 at 09:36 UTC | |
by Anonymous Monk on Feb 10, 2009 at 10:10 UTC | |
by Corion (Patriarch) on Feb 10, 2009 at 10:19 UTC | |
| |
A reply falls below the community's threshold of quality. You may see it by logging in. |
In Section
Cool Uses for Perl