Remove packages from a list of .deb files

I have installed a set of Linux packages from a directory of .deb files. I then wanted to uninstall them, but trying to guess the package names was hard – even harder was wading through the sheer amount of files to remove them! Linux has this weird thing where you can installed from anyrandomname.deb file, but you have to remove by package name.

A bit of Googling and some short script work got me this:

#!/bin/bash

for f in *.deb;
do
 pak="$(dpkg-deb -f "$f" Package)";
# echo $pak $pak
 sudo apt-get remove $pak ;
done

Every deb file is listed, examined and the packages listed then uninstalled by package name. While there may be more elegant ways, this seems to work!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s