LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-05-2014, 10:52 PM   #1
MikeyCarter
Member
 
Registered: Feb 2003
Location: Orangeville
Distribution: Fedora
Posts: 492

Rep: Reputation: 31
Question Find redhat numeric release?


I need to verify by script that someone is using RHEL 6+ I know I can look at the /etc/redhat-release but I need a number so I can do something like:

Code:
if [ $ver -lt 6 ] ; then
  ... do something ...
fi
/etc/redhat-release is text and if it's Fedora or Redhat or other the text can be greatly different.

Any one have an idea?
 
Old 02-06-2014, 03:31 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Maybe lsb_release -r.
 
Old 02-11-2014, 02:08 AM   #3
yooden
Member
 
Registered: Dec 2013
Distribution: Debian Wheezy/Jessie # XFCE
Posts: 53

Rep: Reputation: Disabled
Please post the content of /etc/redhat-release.
 
Old 02-11-2014, 06:22 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
on SL6

Code:
egrep '[0-9\.]{1,}' *-release -oh
 
Old 02-11-2014, 06:38 PM   #5
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by MikeyCarter View Post
I need to verify by script that someone is using RHEL 6+ I know I can look at the /etc/redhat-release but I need a number so I can do something like:

Code:
if [ $ver -lt 6 ] ; then
  ... do something ...
fi
/etc/redhat-release is text and if it's Fedora or Redhat or other the text can be greatly different.

Any one have an idea?
Just one...

Code:
grep -iq "6." /etc/redhat-release
if [[ $? = '0' ]] ; then
echo "Found it"
else
echo "Not RH 6"
fi
Also:
$ver -lt 6 will not work as a comparison for "any version less than 6".
So we look for any thing starting with "6."

Last edited by Habitual; 02-12-2014 at 06:25 AM.
 
Old 02-11-2014, 06:59 PM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Officially, it's the release and version of the rpm that provides /etc/redhat-release.
Code:
ver=$(rpm -q --qf '%{RELEASE}.%{VERSION}' -f /etc/redhat-release)
Major=${ver%.*}
Minor=${ver#*.}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I find what Kernel is in in a given Debian release? C5 Hardtop Debian 8 10-13-2013 01:29 PM
[SOLVED] find varing numeric value and replace it. Kashif_Bash Programming 5 04-19-2012 10:23 AM
where to find Knoppix 5.1 release autan Linux - Newbie 7 04-25-2007 01:02 AM
What goes into a new release of RedHat? maximus power Red Hat 1 05-15-2004 12:29 AM
New Redhat Release Darkstar Linux - Distributions 3 09-13-2002 09:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration