Correct way to determine distro version in bash?
S. Dale Morrey
sdalemorrey at gmail.com
Mon Apr 8 16:30:33 MDT 2013
I was messing around with a couple of scripts today trying to get them to
They were written for CentOS 6 and I've been trying to deploy them under
The problem comes when they check the version number.
One script (which is adding a repo) gets the word Server6 when it's
supposed to be getting the number 6. This breaks the repo URL and causes
the script to fail.
The other script is checking it a different way and ends up with the word
Enterprise and fails because it too was expecting the number 6. Since it's
contained in an if statement it just refuses to load saying that versions
of RedHat prior to 6 are no longer supported.
Obviously there are easy fixes for both, but it just seems a bit of a
kludge to manually try and edit these scripts hardcode the version number.
This got me thinking, is there a correct way to check this sort of thing?
Something that's going to be consistent, at least across direct derivations
such as RHEL & CentOS?
More information about the PLUG