Results 1 to 2 of 2
Hello,
I'm kinda new to using BASH and I would like to know how I can compare two version strings to see if they are Greater than, Less than or ...
- 09-29-2010 #1Just Joined!
- Join Date
- Sep 2010
- Posts
- 1
BASH - Version string compare
Hello,
I'm kinda new to using BASH and I would like to know how I can compare two version strings to see if they are Greater than, Less than or equal.
For example i have these two versions strings
a=10.1.0.53
b=10.1.2.8
Does anyone have an example or sample script on comparing these two version strings?
Thanks,
tom
- 09-29-2010 #2Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 452
if the version strings are in a file "file"
10.1.0.53
10.1.2.8
then
sort -nr <file |head -1
will give you the bigger, but
sort -n <file |head -1
the smallerthe sun is new every day (heraclitus)


Reply With Quote