[CentOS-devel] /etc/redhat-release

Tue Jun 10 20:33:32 UTC 2014
John R. Dennison <jrd at gerdesas.com>

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
-- 
He may be mad, but there's method in his madness.  There nearly always is
method in madness.  It's what drives men mad, being methodical.

-- G. K. Chesterton, The Fad of the Fisherman (1922)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.centos.org/pipermail/centos-devel/attachments/20140610/6a58b84b/attachment-0007.sig>