Solved

Bash string manipulation

Posted on 2013-12-21
5
370 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access_log 17 149
AWS - HAProxy- KeepAlived 5 51
Penetration Testing home based work 3 91
What is linux 4.8.22? Is it the same as ubuntu 16.10 ?? 2 54
Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
Fine Tune your automatic Updates for Ubuntu / Debian
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

860 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