I have following script to check disk usage
#!/bin/bash # set alert level 90% is default ALERT=10 OIFS=$IFS IFS=',' storage=$(df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }') for output in $storage ; do echo "---------------@@@@@@@@@ output started @@@@@@@@@@@@@@@@-----------" echo $output echo "---------------@@@@@@@@@ output end @@@@@@@@@@@@@@@@-----------" usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 ) echo "---------------###### useo started ######-----------" echo $usep echo "---------------###### usep end ######-----------" if [ $usep -ge $ALERT ]; then echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" fi done
But when i am running this code i am getting the integer expression expected error at if conditional statement, Here is the output of this script
97% /dev/sda1 1% udev 0% none 2% none ---------------@@@@@@@@@ output end @@@@@@@@@@@@@@@@----------- ---------------###### useo started ######----------- 97 1 0 2 ---------------###### usep end ######----------- ./fordiskfor.sh: line 24: [: 97 1 0 2: integer expression expected
$usep
contains no integer.