On Tue, Jun 10, 2014 at 03:37:45PM -0400, Fred Smith wrote:
So the pain comes simply in telling which RHEL or centos it is. While I'm sure someone smarter could parse /etc/redhat-release in fewer lines of code than I have, it's still a pain and prone to breakage with each new version. that's where lsb_release -i -r should make life simpler.
For CentOS you can do:
rpm -q centos-release | cut -d. -f 1 | cut -d- -f3- | tr '-' '.'
(Yes, ugly. Works fine, however.)
I've not tried on a RHEL box but exchanging redhat-release for centos-release probably will work there as well.
Depending on contents of /etc/*-release is problematic as it's just a pure text file that can, and often is, modified by the user.
John