?
Solved

Bash string manipulation

Posted on 2013-12-21
5
Medium Priority
?
383 Views
Last Modified: 2013-12-26
On RHEL, version 5.4 and above,
I would like to extract and match the OCFS2 version with the Linux version:

#uname -r
  retruns:  2.6.18-371.3.1.el5PAE

# rpm -qa | grep ocfs
returns two rows:
  ocfs2-2.6.18-238.el5PAE-1.4.7-1.el5
  ocfs2-tools-1.4.4-1.el5

I need to find if the versions match:
 2.6.18-371.3.1.el5PAE with 2.6.18-238.el5PAE (This is from rpm cmd between the two "-")

Thanks
0
Comment
Question by:peledc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 19

Assisted Solution

by:xterm
xterm earned 2000 total points
ID: 39733775
Try this:

rpm -q ocfs2 --qf '%{version}-%{release}\n'

The output should match the format of uname -r.
0
 
LVL 1

Assisted Solution

by:peledc
peledc earned 0 total points
ID: 39734222
Thanks for the help but this returns:
 1.4.7-1.el5
and not
  2.6.18-238.el5PAE
0
 
LVL 1

Accepted Solution

by:
peledc earned 0 total points
ID: 39734239
I found this to be working:
rpm -qa|grep ocfs2 |grep -v ocfs2-tools| cut -d "-" -f 2,3
0
 
LVL 19

Expert Comment

by:xterm
ID: 39734280
Sorry, I didn't have ocfs2-tools installed anywhere to test with.  Nice work getting what you needed though!
0
 
LVL 1

Author Closing Comment

by:peledc
ID: 39739813
My comment best fit this scenario

Thanks for the help.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question