I am making the check for update script for my themeI 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 codeecho Checking update;x=$(cat ./current.txt)y=$(cat ./latest.txt)if [ $x -eq $y ]then       echo There is version $y updateelse       echo Version $x is the latest versionfiWhat 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 versionBut when I try to run it. I get this errorChecking update./test.sh: line 4: [: 4.1.1: integer expression expectedVersion 4.1.1 is the latest versionSo what am I doing wrong with this?
Bash - Integer expression expected
shell script;string;test;numeric data
The test command, also named [, has separate operators for string comparisons and integer comparisons:INTEGER1 -eq INTEGER2INTEGER1 is equal to INTEGER2vsSTRING1 = STRING2the strings are equalandSTRING1 != STRING2the strings are not equalSince your data is not strictly an integer, your test needs to use the string comparison operator. The last realization in the comments was that the -eq logic did not match the sense of the if/else echo statements, so the new snippet should be:...if [ $x != $y ]then       echo There is version $y updateelse       echo Version $x is the latest versionfi