Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
root@SERVER ~$ df
Filesystem  512-blocks  Free    %Used   Iused   %Iused  Mounted on
/dev/YXCV   655360      365632  45% 6322    13% /
/dev/ASDF   3801088     670648  83% 41759   32% /usr
/dev/ASR    1048576     500496  53% 5555    9%  /var

how can I pipe the df commands output to only display lines that has more usage then 80%?

e.g.: it would only display:

/dev/ASDF   3801088     670648  83% 41759   32% /usr
share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

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 '+$5 >= 80 {print}'

Adapt the field number if you want to use your implementation's df output format rather than the POSIX format.

share|improve this answer
df -P | awk '$5 >= 80 {print}' works for me: can you include a note about the benefit of using the substr? Thank you. –  jasonwryan Jun 16 '11 at 9:41
@jasonwryan: I didn't remember offhand whether awk ignored trailing non-numeric characters when interpreting a string as a number. It does, so indeed there's no need to remove the trailing % explicitly. –  Gilles Jun 16 '11 at 9:56
'$5 >= 80 works, ie. it ignores the trailing %, but < > == don't work in the same manner... whereas the (previous edit) subtring version seem to work for most comparison situations, but it too fails when comparing to < 100 ... I guess that is because it is comparing a sub-string.. –  Peter.O Jun 16 '11 at 13:16
@fred: Oh, I see. Numeric conversion does ignore a non-numeric suffix, but the comparison operators work on strings, so here the operator doing a string comparison unless both strings are numeric. The best way is to force the string to a number (with the + operator). –  Gilles Jun 16 '11 at 14:05
add comment
df | egrep "([89][0-9]|100)%"

will do the trick.

share|improve this answer
and what happens when i have 92% free on a mount point? –  LanceBaynes Jun 16 '11 at 7:22
It works fine for 92%; it works fine for 80 thru 100%... I'm quite puzzled about why someone marked it down.... maybe it is because my df output is different.... Aha! I just checked: my default output only shows Filesystem 1K-blocks Used Available Use% Mounted on ... so it just depends on what your output is (as mentioned in Gilles answer).. If there is a second % column (as in the question), a trailing .*% should work: df | egrep "([89][0-9]|100)%.*%" ...Now I understand why someone marked down... –  Peter.O Jun 16 '11 at 14:51
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.