I'm newbie to coding script so i found test: argument expected when i run it. please help me
a=`df -k |awk '{print $5 }'|egrep "(100%|[89][0-9]%)"|cut -d"%" -f1|tail -1`
if [ $a -ne "" ]
then
df -k|egrep "(100%|[89][0-9]%)"|awk '{print $1,$5,$6}'
else
echo "No disk capacity more than 80%"
fi
if [ "$a" -ne "" ]
is legal. It will be true if $a is a non-zero integer. You're right that the user probably meant to use "!=" here. It seems to be working because the output is constrained to an integer greater than 80.
Now that I'm awake, I see a second problem as well. Some filesystems based on the McKusick filesystem have a minfree parameter which reserves disk space that can never be allocated except by root. 100% is often reported when the non-reserved soace has been exhausted. At this point, a non-root user cannot allocate any more space. However, a root process can continue to allocate space and this drives the number reported by df above 100%.