I am trying to get the usage-percentage for a given disk in a system. The program I have to write will be a
bash shell script. The script has to work on Debian, Arch, and Mac OS X.
My current approach is to do a
df and grep for the usage percentage. The problem is that the output of
df differs on these systems. I want to avoid
if os==Arch elseif os == Debian…as far as possible.
Is there a solution which avoids distinguishing the OS?
Example output for each operating system / version of
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on /dev/disk2 179032136 106162416 72357720 60% 13334300 9044715 72% /
Filesystem 1K-blocks Used Available %used Mounted on /dev/hdv1 20480000 8423436 11016564 44% /
Filesystem 1K-blocks Used Available Use% Mounted on /dev/root 5160576 813420 4085012 17% /
So Arch and Debian are pretty the same. It may also be a problem that the labels are maybe printed in different languages.