I am not sure I follow the logic (in general, not the script). Do you require intermediate items to be installed as you go from version to version?
As an example, if current is 1.1.5 and we need to upgrade to 1.2.1, do we need to firstly install all for 1.1.8 prior to installing those for 1.2.1?
If you simply need to install all from the latest version, you could do something like:
Code:
latest_v=$(sort -V <<<"$(echo -e "$installed_ver\n$target_ver")")
[[ "$latest_v" == "$installed_ver" ]] || echo "time to upgrade :)"