Sample Header Ad - 728x90

Compare multi-digit version numbers in bash

5 votes
6 answers
12144 views
Trying to write a script that searches for the version of the Application then returns the value. My problem is the value is three to four intergers long (example 4.3.2). I have searched for a while and can't find any syntax that would allow you to use a != or -ge for anything higher than a number with periods in it. Just wondering if anyone has a better way or I will just keep adding for every version release. ### What I want else if [ $version1 -ge "9.0.8" ]; then ### How it is written now vercheck=mdls -name kMDItemVersion /Applications/iMovie.app version=echo ${vercheck:17} version1=echo ${version:1:5} [...] else if [ $version1 = "9.0.8" ]; [ $version1 = "9.1.1" ]; then echo "You already have this version or a higher version installed" exit 0
Asked by balooga1 (51 rep)
Mar 1, 2013, 04:52 PM
Last activity: Aug 6, 2025, 04:04 AM