LinuxQuestions.org
Review your favorite Linux distribution.
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-02-2012, 02:17 PM   #1
arijspieter
Member
 
Registered: Oct 2012
Location: /home
Distribution: Debian
Posts: 32

Rep: Reputation: 1
bash script to remove orphaned packages


i'm running Debian Wheezy and i'm trying to make a bash script which will remove all orphaned packages
i installed deborphan and this is my code:
Code:
#! / bin / bash

echo `deborphan > deborphan.txt`

while [[ -s deborphan.txt ]]
do
	while read LINE
	do
		CMD=$(apt-get remove --purge $LINE)
		$CMD
	done < deborphan.txt
	
	echo `deborphan > deborphan.txt`
done
anybody here who can help me making this script work?
thanks
 
Old 11-02-2012, 04:19 PM   #2
DutchGeek
Member
 
Registered: Sep 2006
Distribution: SuSE, Slackware
Posts: 55

Rep: Reputation: 4
So you'r trying to remove orphaned packages, then see if the removal will create other orphaned packages and remove those too etc.?

at the line where you execute CMD, try:

Code:
echo $CMD
instead
 
Old 11-02-2012, 04:46 PM   #3
craigevil
Senior Member
 
Registered: Apr 2005
Location: OZ
Distribution: Debian Sid
Posts: 4,734
Blog Entries: 12

Rep: Reputation: 461Reputation: 461Reputation: 461Reputation: 461Reputation: 461
apt-get autoremove

deborphan | xargs apt-get -y remove --purge
deborphan --guess-all | xargs apt-get -y remove --purge
deborphan --guess-dev | xargs apt-get -y remove --purge

or aptitude purge ~o (careful this one will remove any manually installed packages that are not in the repos)
remove any leftover config files
aptitude purge ~c
 
1 members found this post helpful.
Old 11-02-2012, 10:47 PM   #4
arijspieter
Member
 
Registered: Oct 2012
Location: /home
Distribution: Debian
Posts: 32

Original Poster
Rep: Reputation: 1
thanks guys, got a working script now

Code:
#! / bin / bash

echo $(deborphan > deborphan.txt)

while [[ -s deborphan.txt ]]
do
	echo $(deborphan | xargs apt-get -y remove --purge)
	echo $(deborphan > deborphan.txt)
done
 
1 members found this post helpful.
  


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
LXer: How does your package manager handle orphaned packages? LXer Syndicated Linux News 0 12-06-2011 10:10 PM
Is It Ok To Uninstall These Orphaned Packages? taurusx5 Linux - Software 6 08-13-2008 12:42 PM
Need a script to remove packages by date samac Slackware 3 07-21-2008 09:33 AM
What are orphaned packages? Fill Linux - Software 2 04-06-2008 08:10 PM
How to remove orphaned packages? lnthai2002 Linux - Software 8 02-03-2006 10:48 PM


All times are GMT -5. The time now is 08:08 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