Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get the names of all disks with at least 90% usage, using this oneliner:

df -Pm | awk '+$5 >= 90 {print}'

But it doesn't show the "100% usage" case, I need to grep for "100%". Why doesn't it work correctly?

share|improve this question
what version of awk are you running? – glenn jackman Aug 30 '11 at 13:32
I just dd'd my disk usage so I had both 100% used on one fs and between 90 and 100 on another and I got both reported. Used your exact syntax. – Kevin M Sep 7 '11 at 17:22

Could you give us an example output from df -Pm ? I'm sure most of us don't have 100% or their disk space used ;)

i just tested by hacking up my df's output and your awk part seems to be fine.

$ cat /tmp/1 | awk '+$5 >= 90 {print}'
tmpfs                        1978         1      1978     101% /dev/shm
tmpfs                        1978         1      1977     100% /run
share|improve this answer

I assume the problem is the percentage sign, which probably turns the >= into a string comparison. Add 0 to $5 before doing the comparison, this way you force $5 to be interpreted as a number:

df -P | awk '0 + $5 >= 90 { print }'
share|improve this answer

I suggest a slightly alternate approach. A little math never hurt anyone.

df -Pml | tail -n +2 | awk '{if ($4/$2 < 0.1) print $1,"is getting full."}'

This will calculate wether the filesystem is less than 10% free (which is actually how df displays it, even though the column is labeled "Used", and the -l prints only local filesystems). Throwing in tail -n +2 skips the header.

share|improve this answer

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.