Remove packages that match a regular expression

From raju

To remove all packages whose name matches with a regular expression

Approach 1

% apt-show-versions -r kde | cut -f1 -d':' > pkg_list.txt
% xargs -a pkg_list.txt sudo apt-get remove

The first command generates the package list and the second command removes them. In the xargs command, "-a" specifies the file the input is read from.

Approach 2

% sudo apt-get remove ".*kde.*"