LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 09: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, 09:51 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
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, 02:03 PM   #3
kbscores
Member
 
Registered: Oct 2011
Location: USA
Distribution: Red Hat
Posts: 259

Original Poster
Blog Entries: 9

Rep: Reputation: 32
Thanks that worked.
 
  


Reply



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 03:12 AM
determine what packages depend on a given rpm bradvan Linux - Software 7 05-07-2009 09:22 AM
Determine installed perl bundles/packages Harry Seldon Linux - General 2 05-24-2007 11:53 AM
Problem Installation linux on single drive co-exist with windows XP pro...help lionelchia1986 Linux - General 8 02-19-2007 02: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 05:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:42 AM.

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
Open Source Consulting | Domain Registration