#!/usr/bin/perl -w use strict; my @df = `df -k`; # get filesystem listing shift @df; # lose the header my %df; for (@df) { # go through each line, splitting it out into columns and storing # that in a hash-of-hashes: my ($disk, $blks, $used, $avail, $cap, $mount)= split; $df{$disk} = { blocks => $blks, used => $used, available => $avail, capacity => $cap, mount => $mount }; } # find the root file system, and how much room is left on it: my ($root) = grep { $df{$_}{mount} eq "/" } keys %df; print "root disk = $root; available = $df{$root}{available} kB\n"; # get total available space on system: my $total_avail = 0; foreach my $avail (map { $_->{available} } values %df) { $total_avail += $avail; } print "total available = ${total_avail} kB\n"; exit 0;