Issue
Which the best way to check that we have minimum require version software in bash script. E.g. git 2.16.2
id='dv4'>
Solution
git
provides its version info like this:
$ git --version
git version 2.11.0
GNU sort
understands version numbers and can sort them:
$ (echo min version 2.16.3; git --version) | sort -Vk3
git version 2.11.0
min version 2.16.3
$ (echo min version 2.9.3; git --version) | sort -Vk3
min version 2.9.3
git version 2.11.0
We can combine this to make a test:
if (echo a version 2.16.3; git --version) | sort -Vk3 | tail -1 | grep -q git
then
echo "Good enough."
else
echo "Not good"
fi
Answered By - John1024 Answer Checked By - Terry (WPSolving Volunteer)