we have the following df -h output
[root@trump var]# df -h | grep "/var"
/dev/mapper/vg-lvm_var 101G 85G 17G 84% /var
how to verify at least 10G free space on /var in bash/awk/perl one liner
meanwhile I write this syntax :
[[ ` df -h | grep "/var" | awk '{print $4}' | sed s'/G//g' ` -lt 10 ]] && echo "/var need at least 10G"
but this syntax isn't elegant and ugly and maybe I missed some rules
df -BG /var | tail -n1
would be much more reliable an elegant as it will always display Giga Bytesdf
or calculations withinawk
. (And yes,df
is also incorrect in this regard.)-BG
is Gibibytes (2^n) and-BGB
is Gigabytes (10^n). This confusion is exactly why I'm asking for clarification.