LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 11-18-2009, 04:39 AM   #1
mjr4077au
LQ Newbie
 
Registered: Sep 2009
Posts: 9

Rep: Reputation: 0
Using Yum and Grep together


Hello all,

N00bie question, but I was reading this guide for akmod that I cannot find again. In this guide, it explained a way of removing all NVIDIA packages using a combination of Yum and Grep to do it.

I have just upgraded from Fedora 11 to Fedora 12 and wanted to remove some orphaned Fedora 11 packages that didn't get erased. I thought this would be an easy way to do it.

If anyone can help, it'd be great .


Cheers, Mitch.
 
Old 11-18-2009, 06:32 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156
*

1) su

2) yum list installed | grep fc11
 
Old 11-18-2009, 07:35 AM   #3
DaveQB
Member
 
Registered: Oct 2003
Location: Sydney, Australia.
Distribution: PCLinuxOS 2010.12, Debian Lenny
Posts: 396

Rep: Reputation: 38
Code:
rpm -qa |grep fc11 > TEMP
while read pac ; do yum -y remove $pac ; done < TEMP
rm -f TEMP
Something like that should work.

To test it, just get it to print what it would do:

Code:
rpm -qa |grep fc11 > TEMP
while read pac ; do echo yum -y remove $pac ; done < TEMP
rm -f TEMP
 
Old 11-18-2009, 04:02 PM   #4
mjr4077au
LQ Newbie
 
Registered: Sep 2009
Posts: 9

Original Poster
Rep: Reputation: 0
Hi Guys,

The "yum list installed | grep fc11" does work, just not 100% sure why I can't use it with the "erase" parameter.

I haven't tried that script, but it's certainly interesting. I'm going to try and learn more about bash scripting .

Thanks for the quick responses, guys .


Cheers, Mitch.
 
Old 11-18-2009, 05:31 PM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,991

Rep: Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448
you could use "DaveQB" script BUT I WOULD NOT .

there is a -y tag in it

THAT IS VERY BAD

and something that WILL at some point kill a system from a simple typo .

from
Code:
yum list installed | grep fc11
that will give you a list .If it is long or you want a text copy you could do this
" yum list installed | grep fc11 > ~/f11.txt " and you will have a text file in your home folder

then

one at a time remove the fedora 11 rpm's
this is THE SAFEST WAY
"yum erase filename"
 
Old 11-18-2009, 07:26 PM   #6
DaveQB
Member
 
Registered: Oct 2003
Location: Sydney, Australia.
Distribution: PCLinuxOS 2010.12, Debian Lenny
Posts: 396

Rep: Reputation: 38
John VV is right in this situation.
The snippet I gave I have used to rip out 32bit packages on 100 or so machines, so it was scripted.
 
Old 11-19-2009, 01:24 AM   #7
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,991

Rep: Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448Reputation: 2448
the main thing is with yum ( install or remove) the -y tag can be very dangerous .

i would not use it until you DO KNOW EXACTLY what you are doing
this is a example - DO NOT RUN THIS !!!!
"yum erase -y glibc "

the above will remove about 95% of the operating system
 
Old 11-19-2009, 03:56 AM   #8
mjr4077au
LQ Newbie
 
Registered: Sep 2009
Posts: 9

Original Poster
Rep: Reputation: 0
Hi Guys,

I know the "-y" tag gives an automatic yes to everything. I have left the packages for now as I originally thought they were orphans from the upgrade, but they seem to be getting updated automatically from the Repos over time. I assume some apps just weren't packaged in time for F12 to release.

John VV is certainly right. By telling yum to erase all the fc11 packages left over wanted to remove over 200 packages, including "yum" and "rpm". That would have been disastrous for me!


Cheers, Mitch.
 
  


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
yum install flash ... yum: command not found ... which yum ... /usr/bin/yum tg3793 Fedora 8 04-13-2011 12:25 PM
Trying to understand pipes - Can't pipe output from tail -f to grep then grep again lostjohnny Linux - Newbie 15 03-12-2009 11:31 PM
how to grep multiple filters with grep LinuxLover Linux - Enterprise 1 10-18-2007 08:12 AM
bash script with grep and sed: sed getting filenames from grep odysseus.lost Programming 1 07-17-2006 12:36 PM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 12:38 PM


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