The following shell scrip will check the disk space and change the variable diskfull to 1 if the usage is more than 10%
The last echo always shows
I think you must not be getting to the diskfull=1 line, because if you were, you would get no output at all-- the following exit line would exit the script.
I don't know why this isn't working, but note that awk can handle the rest of the work:
diskfull=$(df -HP | grep -vE '^Filesystem|tmpfs|cdrom' | awk 'BEGIN { x = 0 } { if ($5 + 0 >= '$ALERT') { x = 1 } } END { print x }')
This way you don't need the while loop.