I'm trying to find some sort of command or regex to get the size and available or used space of a hard drive in linux.
At the moment I'm using this;
df -h
and getting something like this;
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 10G 3.1G 6.4G 33% /
/dev/sda2 147G 5.8G 134G 5% /mnt
What I need is to be able to, per drive, collect the Size, Used and Avail values. Any thoughts on how I could go about collecting that data?
EDIT: Since I apparently wasn't quite clear enough, here's basically what I want the end result to be;
array(
'/dev/sda1' => array(
'size' => '10G', 'used' => '3.1G', 'avail' => '6.4G'
),
'/dev/sda2' => array(
'size' => '147G', 'used' => '5.8G', 'avail' => '134G'
)
)
Either that or each partition being in it's own separate array, rather than a master array.