# Ubuntu – How to delete all packages which match a certain pattern

aptaptitude

I want to uninstall libreoffice. This program consists of about three dozen modules. Ideally, they could be removed with:

aptitude remove libreoffice3.6* libreoffice-debian-menus libobasis3.6-*


but that fails with

Couldn't find any package whose name or description matched "libreoffice3.6*"


etc.

How do I delete a set of packages by pattern?

PS: I'm happy about answers with use dpkg or apt, too

1. Use apt-get, not aptitude, and use regular expressions.
2. In a regular expression, . mean any character, and * means zero or more times. So the expression libreoffice.* matches any package name containing the string libreoffice, followed by any number of characters.
3. Surround the regular expression with single quotes to avoid the shell interpreting the asterisk. (If you had a file named libreoffice.example for example in your current directory, the shell would replace libreoffice.* with libreoffice.example, so you have to use single quotes to stop this behaviour.)
sudo apt-get remove 'libreoffice.*'