Changing a non-integer to integeter

Closed
Report
Posts
1
Registration date
Thursday May 14, 2015
Status
Member
Last seen
May 14, 2015
-
I'm issuing a df command to check usage. In some cases the response is a '-' vs. integer. For example:
Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/hd4 1.00 0.79 22% 10870 6% /
/proc - - - - - /proc

I originally had:
WARNING=70
CRITICAL=90
for FS in $(df -g | awk '{print $7}' | grep -vE 'Mount|%Iused')
do

PCT="$(df -g ${FS} | grep -v Use | awk '{print $6}' | tr -d '%')"
if [[ ${PCT} -lt ${WARNING} ]]
then echo "OK - Disk space for $FS is good"
elif [[ ${PCT} -gt ${CRITICAL} ]]
then echo "CRITICAL - Disk space for ${FS} is at ${PCT}"
else echo "WARNING - Disk space for ${FS} is at ${PCT}"
fi
done


How do I change it so that PCT will always be numeric? I started to add this code but it seems cumbersome:
PCT="$(df -g ${FS} | grep -v Use | awk '{print $6}' | tr -d '%')"
if let $PCT 2>/dev/null
then
# $PCT is numeric
PCT=$PCT
else
PCT=0
fi