Bash string manipulation

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
LVL 1
peledcAsked:
Who is Participating?
 
peledcConnect With a Mentor Author Commented:
I found this to be working:
rpm -qa|grep ocfs2 |grep -v ocfs2-tools| cut -d "-" -f 2,3
0
 
xtermConnect With a Mentor Commented:
Try this:

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

The output should match the format of uname -r.
0
 
peledcConnect With a Mentor Author Commented:
Thanks for the help but this returns:
 1.4.7-1.el5
and not
  2.6.18-238.el5PAE
0
 
xtermCommented:
Sorry, I didn't have ocfs2-tools installed anywhere to test with.  Nice work getting what you needed though!
0
 
peledcAuthor Commented:
My comment best fit this scenario

Thanks for the help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.