Results 1 to 4 of 4
I am interested in testing version numbers within bash script.
I have googled for good examples but have not seen what I am looking for..
if a product were to ...
- 06-02-2010 #1Just Joined!
- Join Date
- Sep 2003
- Location
- hants
- Posts
- 2
bash script testing version numbers
I am interested in testing version numbers within bash script.
I have googled for good examples but have not seen what I am looking for..
if a product were to be be on version
3.33.10
How to check that that the patch was only 3.33.11 or version 3.34.0
for instance it could be that the next patch is a patch and it will only upgrade the version number by one or it is a release and will move totally away.
3.33.11 would be valid
3.33.12+ would fail
3.34.0 would be valid
but 3.34.1 would fail
or 3.34.01 would fail
If I have not explained full please do ask away...
Thanks for reading
hdaz
- 06-02-2010 #2Linux Newbie
- Join Date
- Sep 2004
- Location
- UK
- Posts
- 160
Break the new version and old version numbers to major, minor and revision numbers
eg.
Then code the logic to compare the numbers.Code:OLD_VERSION=2.3.11 NEW_VERSION=2.3.12 c_major c_minor c_rev << EOF `echo ${OLD_VERSION} | tr "." " "` EOF read n_major n_minor n_rev << EOF `echo ${NEW_VERSION} | tr "." " "` EOFIn a world without walls and fences, who needs Windows and Gates?
- 06-03-2010 #3Just Joined!
- Join Date
- Sep 2003
- Location
- hants
- Posts
- 2
blinky,
Many thanks for the fast reply... my memory is failing me I have seen this example before someplace...
Thanks
- 06-03-2010 #4Linux Newbie
- Join Date
- Sep 2004
- Location
- UK
- Posts
- 160
Should be a read at the start of line "c_major c_minor c_rev << EOF"
eg.
Code:OLD_VERSION=2.3.11 NEW_VERSION=2.3.12 read c_major c_minor c_rev << EOF `echo ${OLD_VERSION} | tr "." " "` EOF read n_major n_minor n_rev << EOF `echo ${NEW_VERSION} | tr "." " "` EOFIn a world without walls and fences, who needs Windows and Gates?


Reply With Quote