only display df lines that have more fs usage than 80%
Assuming you don't have device names containing spaces (which are a pain when it comes to parsing the output of df
):
df -P | awk '0+$5 >= 80 {print}'
Adapt the field number if you want to use your implementation's df
output format rather than the POSIX format.
Without the 0+
, the comparison would be lexical (9%
would then be greater than 80
). By using the +
binary arithmetic operator, we force $5
to be converted to a number (so 9%
becomes 9
) and the comparison to be numerical. Using the +
unary operator (as in awk '+$5 >= 80'
) works in some awk
implementations but not in traditional ones (the ones written by A, W and K) where that operator is just ignored.