Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is there a way to use wildcards with aptitude such as in the following:

sudo apt-get remove openoffice*.*
share|improve this question

3 Answers 3

up vote 11 down vote accepted

http://ubuntuforums.org/showthread.php?t=228309 indicates that it's possible via constructs such as ~n<package name> and this is confirmed by the user manual http://algebraicthunk.net/~dburrows/projects/aptitude/doc/en/ch02s03s02.html.

~n in ~n<package name> is a search pattern for matching package names. It's also possible to match other fields than packages' names, see http://algebraicthunk.net/~dburrows/projects/aptitude/doc/en/ch02s03s05.html#tableSearchTermQuickGuide.

Here's an example. Say that you want aptitude to show every package with "redshift" in its name, then you issue

aptitude show ~nredshift

It should be combinable with other aptitude options, such as install and remove, too, e.g. to remove all installed packages with openoffice in their name you issue

sudo aptitude -P remove ~nopenoffice

Make sure to use the -P option when using search patterns to force aptitude to display a prompt before downloading, installing or removing packages (the search pattern might have many matches and you'll want to be prompted before carrying out an action).

One thing that I haven't worked out is how to get the exact functionality of wildcards, e.g. that openoffice* matches every string starting with "openoffice" (~nopenoffice matches any string containing "openoffice"). Maybe a workaround is possible, e.g. to search for installed packages with a certain string in their names and then feed aptitude with their names.

share|improve this answer

You just put it in quotes:

sudo apt-get remove "openoffice*"

Otherwise the shell would try to match this to the files of your current working directory.

share|improve this answer
3  
The question is about aptitude and not apt-get. This solution does not work with aptitude. –  N.N. Sep 23 '11 at 10:39
    
@MichałŠrajer: no pathname expansion occur in quotes, both single and double –  enzotib Sep 23 '11 at 12:01
    
@enzotib: My mistake. Thanks for pointing it out. Removed comment. –  Michał Šrajer Sep 23 '11 at 14:07
    
ok, I don't get ... so can be done with aptitude or work in that way... sudo aptitude remove "openoffice*" –  raulricardo21 Sep 23 '11 at 14:40
    
@raulricardo21 A similar thing can be done with aptitude, see my answer. –  N.N. Sep 23 '11 at 15:11

To match strings starting with a package name, prepend a ^ in front of it.
e.g: aptitude search ~n^openoffice

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.