testif.sh: 10: [: Illegal number: 4.0 - Why I am getting this error even in simple script. M tired. Plz help.
by Vishesh Joshi from LinuxQuestions.org on (#6K1SV)
#!/bin/bash
#test if else script
cd /root/task
pwd
ab=`du -h | cut -c 1,2,3 | grep 4.0`
echo $ab
if [ $ab -eq "4.0" ]
then
echo "$ab is Rightly fetched."
else
echo "$ab is not correctly fetched."
fi
#test if else script
cd /root/task
pwd
ab=`du -h | cut -c 1,2,3 | grep 4.0`
echo $ab
if [ $ab -eq "4.0" ]
then
echo "$ab is Rightly fetched."
else
echo "$ab is not correctly fetched."
fi