I am making the check for update script for my theme
I have 2 text files. First one is called "current.txt" and contains the current version. There is 4.1.1
string in that text file.
Second one is called "latest.txt" and contains the latest version. There is 4.2
string in this text file.
So here is the code
echo "Checking update";
x=$(cat ./current.txt)
y=$(cat ./latest.txt)
if [ "$x" -eq "$y" ]
then
echo There is version $y update
else
echo Version $x is the latest version
fi
What it mean is if current.txt is NOT the same with latest.txt then it will say "there is version 4.2 update". If not, it will say "version 4.1.1 is the latest version"
But when I try to run it. I get this error
Checking update
./test.sh: line 4: [: 4.1.1: integer expression expected
Version 4.1.1 is the latest version
So what am I doing wrong with this?
x=$(< ./current.txt)
-- that's builtin, so you don't need to call out to cat (ref here) – glenn jackman Jul 02 '16 at 20:00