Solved

Bash string manipulation

Posted on 2013-12-21
5
367 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
  • 3
  • 2
5 Comments
 
LVL 19

Assisted Solution

by:xterm
xterm earned 500 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now