Script to compare version numbers
Posted on 2003-03-07
I'm struggling with a script I've written to compare version numbers of software installed on my server. Bascially what the script needs to do is check the version of software currently installed, and if the version is smaller than the new version I'm trying to install, then it's OK to go ahead and install the new software. If the version on the server is greater than the software I'm trying to install it should notify me that the installation should not take place.
Version numbers could look like the following:
The normal way I would have tested:
if [ $CURRENTVER -lt $NEWVER ]
is not acceptable because it will only look at the first digit before the .
The above piece of code "sees" 1.3.1 as "1" and therefore will tell me that a version 1.4.0 is equal to the version of 1.3.1 which obviously it's not.
I'm using ksh
Can anyone give me a hand here?