LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-08-2013, 10:32 AM   #1
kbscores
Member
 
Registered: Oct 2011
Location: USA
Distribution: Red Hat
Posts: 259
Blog Entries: 9

Rep: Reputation: 32
How to determine if two packages exist in a single if


Currently - i'm checking to see if a single package exists like so:
Code:
rpm -qa --qf "%{n}-%{v}.%{arch}\n"|grep -i glibc-2.5.i386
if [ $? -eq 0 ]
  then
    rpm -e glibc-2.5.i386
fi
I really need to check for two packages, because I only really want to remove it if both packages exist. Is there a way to do this in a single if statement? I know I can use two nested if statements, but would really like to minimize it.
 
Old 08-08-2013, 10:51 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,783
Blog Entries: 1

Rep: Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339
Well,..

Code:
(rpm -qa --qf "%{n}-%{v}.%{arch}\n"|grep -i glibc-2.5.i386) && \
(rpm -qa --qf "%{n}-%{v}.%{arch}\n"|grep -i glibc-3.5.i386) && \
rpm -e glibc-2.5.i386 && \
rpm -e glibc-3.5.i386
Or you can use 'if' if you'd like,.. this is quick and simple.

Code:
Lookup package && lookup package && if both are there, remove 1st && if that worked, remove the second.
 
Old 08-08-2013, 03:03 PM   #3
kbscores
Member
 
Registered: Oct 2011
Location: USA
Distribution: Red Hat
Posts: 259
Blog Entries: 9

Original Poster
Rep: Reputation: 32
Thanks that worked.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Exist really any difference [dvd vs cd] or is just language packages ? lse123 Fedora 2 07-19-2009 04:12 AM
determine what packages depend on a given rpm bradvan Linux - Software 7 05-07-2009 10:22 AM
Determine installed perl bundles/packages Harry Seldon Linux - General 2 05-24-2007 12:53 PM
Problem Installation linux on single drive co-exist with windows XP pro...help lionelchia1986 Linux - General 8 02-19-2007 03:10 PM
how do you determine the max number files can be stored in a single directory on the genux33 Linux - General 2 12-13-2005 06:40 PM


All times are GMT -5. The time now is 03:15 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration