Article 5CPQD Integer Expression Expected Error

Integer Expression Expected Error

by
jitesh1788
from LinuxQuestions.org on (#5CPQD)
Hi All,
I am trying to execute below script and getting Integer Expression Expected Error:

ecount=`tail -1 countfile.txt`
ncount=580
echo "ecount=${ecount}"
echo "ncount=${ncount}"
if [ ${ecount}" -eq ${ncount}" ];
then
echo Count is matching"
else
echo count is not matching"
fi

Note: I have 580 in the countfile.txt.
I am assuming while doing tail -1 countfile.txt it returns 580 but its string hence wile comparing in If statement its giving this error.
I wanted to know how can I convert 580 coming from file to integer so that If statement works properly.

Any help is appreciated.latest?d=yIl2AUoC8zA latest?i=xyI579Wsptg:XYji7M3vNos:F7zBnMy latest?i=xyI579Wsptg:XYji7M3vNos:V_sGLiP latest?d=qj6IDK7rITs latest?i=xyI579Wsptg:XYji7M3vNos:gIN9vFwxyI579Wsptg
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments