Df -h | awk - output incorrect matching

Running solaris 9, on issuing the follwing command

df -h | awk '$5 > 45 {print}'

Filesystems with utilisation > 45% are being displayed as well as those between
5 and-9%!!!

Try this

df -h | awk '$5+0 > 45'

If it doesn't work, provide the output of df -h

And in Solaris, use nawk

1 Like

nawk gives the same response as awk

$  df -h | awk '$5 > 75 {print}'
Filesystem             size   used  avail capacity  Mounted on
a/b/c/         20G   1.4G    18G     8%    /blah/blah
w/x/y        30G    24G   5.6G    82%    /some/where

---------- Post updated at 10:58 AM ---------- Previous update was at 10:47 AM ----------

I've managed to resolve the issue by doing the following

df -h | tr -d '%' | awk '$5 > 75 {print}'

Hello,

Could you please try following.

df -h | tr -d '%' | awk 'NR==1 {next} $5+0 > 75 {print}' 
 
OR
 
df -h | tr -d '%' | awk '$5+0 > 75 {print}' 
 

Thanks,
R. Singh