UNIX file system free space, used space, total space

Anyone have an idea about getting UNIX file system free space, used space,
total space numbers without having to resort to something like the following
( which gets the percent of used space for a command-line supplied file
system name stored in the variable ${file_sys} ):
$per_used = `df -k | grep " ${file_sys}\$" | awk '{print \$5}'`;
> Anthony (Tony) Esposito
> Senior Technical Consultant 
> Inovis(tm), formerly Harbinger and Extricity
> 2425 N. Central Expressway, Suite 900 
> Richardson, TX  75080 
> (972) 643-3115 
> tony.esposito@inovis.com 
> 
> 
0
tony
3/18/2003 9:41:15 PM
📁 perl.beginners
📃 29388 articles.
⭐ 4 followers.

💬 3 Replies
👁️‍🗨️ 2318 Views


Tony Esposito wrote:
> 
> Anyone have an idea about getting UNIX file system free space, used space,
> total space numbers without having to resort to something like the following
> ( which gets the percent of used space for a command-line supplied file
> system name stored in the variable ${file_sys} ):
> 
> $per_used = `df -k | grep " ${file_sys}\$" | awk '{print \$5}'`;

my ($per_used) = `df -k` =~ m|^\Q$file_sys\E.*?(\d+)%|m;

John
-- 
use Perl;
program
fulfillment
0
krahnj
3/18/2003 11:20:36 PM
Tony Esposito wrote:
> Anyone have an idea about getting UNIX file system free space, used space,
> total space numbers without having to resort to something like the
> following ( which gets the percent of used space for a command-line
> supplied file system name stored in the variable ${file_sys} ):
> 
> $per_used = `df -k | grep " ${file_sys}\$" | awk '{print \$5}'`;
> 
try:
#!/usr/bin/perl -w
use strict;
use Filesys::DiskFree;
(my $disk = Filesys::DiskFree->new)->df;
print "total: ",$disk->total('/'),"\n";
print "used: ",$disk->used('/'),"\n";
print "available: ",$disk->avail('/'),"\n";
__END__
prints:
total: 8589885440
used: 4378312704
available: 3775221760
david
0
dzhuo
3/19/2003 5:51:37 PM
Good suggestion.....now I just need to get Filesys.pm installed on my
system.
Thanks!
-----Original Message-----
From: david [mailto:dzhuo@looksmart.net]
Sent: Wednesday, March 19, 2003 11:52 AM
To: beginners@perl.org
Subject: Re: UNIX file system free space, used space, total space

Tony Esposito wrote:
> Anyone have an idea about getting UNIX file system free space, used space,
> total space numbers without having to resort to something like the
> following ( which gets the percent of used space for a command-line
> supplied file system name stored in the variable ${file_sys} ):
> 
> $per_used = `df -k | grep " ${file_sys}\$" | awk '{print \$5}'`;
> 
try:
#!/usr/bin/perl -w
use strict;
use Filesys::DiskFree;
(my $disk = Filesys::DiskFree->new)->df;
print "total: ",$disk->total('/'),"\n";
print "used: ",$disk->used('/'),"\n";
print "available: ",$disk->avail('/'),"\n";
__END__
prints:
total: 8589885440
used: 4378312704
available: 3775221760
david
-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
0
tony
3/19/2003 6:14:01 PM
Reply: