rempkg - package remover

Submitted scripts and programs
Forum rules
Your own work only.
machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

rempkg - package remover

Unread post by machinebacon » Wed Apr 15, 2015 9:36 am

It's a frontend for apt-get autoremove --purge using dialog

Careful, it bites. Remove the -y option if you want a safety net.

Code: Select all

#!/bin/bash
. /usr/share/doc/dialog/examples/setup-vars
. /usr/share/doc/dialog/examples/setup-tempfile

dpkg --get-selections | awk -F ' '  '{ print $1 }' > ~/.pkglist

ar=()
while read n s ; do
	ar+=($n "$s" "\n")
done < ~/.pkglist

dialog --clear --backtitle "Remove Packages"  --checklist "Select packages to remove" 26 45 30 "${ar[@]}" 2> $tempfile
retval=$?
case $retval in
	$DIALOG_CANCEL)
		rm ~/.pkglist &>/dev/null
		reset
		clear
		exit 0;;
esac
sudo apt-get -y autoremove --purge `cat $tempfile`
rm ~/.pkglist &>/dev/null
Attachments
rempkg.png
..gnutella..

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: rempkg - package remover

Unread post by GekkoP » Wed Apr 15, 2015 9:50 am

This is like the evil version of my frenchmaid! Cool.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: rempkg - package remover

Unread post by machinebacon » Wed Apr 15, 2015 9:58 am

Frenchmaid in stilettos and strap-on :D
..gnutella..

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: rempkg - package remover

Unread post by machinebacon » Thu Apr 16, 2015 9:43 am

This version lets you enter a string and then shows the installed packages containing said string.

Code: Select all

#!/bin/bash
. /usr/share/doc/dialog/examples/setup-vars
. /usr/share/doc/dialog/examples/setup-tempfile

dpkg --get-selections | awk -F ' '  '{ print $1 }' > ~/.pkglist1

ar=()
while read n s ; do
	ar+=($n "$s" "\n")
done < ~/.pkglist1

dialog --clear --title "Package search" --inputbox "Enter the string to grep all installed packages for" 0 0 2> $tempfile
retval=$?

grep `cat $tempfile` ~/.pkglist1 > ~/.pkglist2
while read n s ; do
        arr+=($n "$s" "\n")
done < ~/.pkglist2

dialog --clear --backtitle "Remove Packages"  --checklist "Select packages to remove" 26 45 30 "${arr[@]}" 2> $tempfile
retval=$?
case $retval in
	$DIALOG_CANCEL)
		rm ~/.pkglist* &>/dev/null
		reset
		clear
		exit 0;;
esac
sudo apt-get -y autoremove --purge `cat $tempfile`
rm ~/.pkglist* &>/dev/null
..gnutella..

Post Reply