Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

What I want do is to purge (via aptitude purge) every package installed with a given string in its name.

E.g. apache2. I've got several packages with the string apache2 in their name installed on a system. Now I want to aptitude purge apache2 (like apache2, apache2.2-bin, libapache2-mod-ruby, etc.). But I do not find a way to do this.

Thanks for your answers in advance.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

A quick troll through the Aptitude Reference Manual on patterns I found this entry.

Working from that, aptitude purge ?name('apache2') will do what you want, but if you're wise you'll run it with -s the first time so you can see what all it'll remove before committing to the task.

share|improve this answer
    
Thanks, that's what I was looking for. –  Ulf Klose Oct 31 '11 at 12:30
    
Meanwhile I had the opportunity to try this. Unfortunately, it doesn't work :(. -bash: Syntaxfehler beim unerwarteten Wort (' (Syntax error on unexpected word (') –  Ulf Klose Nov 10 '11 at 13:34
    
You may need to escape the ()s from your shell. –  Shadur Nov 10 '11 at 14:34
    
This works brilliantly and as mentioned by @Shadur it has to be escaped as sudo aptitude purge ?name\('apache2'\) –  kontinuity Dec 12 '12 at 10:21

I would parse the output of dpkg --get-selections, doing something along the following.

$ dpkg --get-selections | cut -f 1 | grep apache | sudo xargs aptitude purge -y

(For better understanding, feel free to try the pipe out one step at a time.)

share|improve this answer
    
That was what I feared first, that I had to use the xargs command. But I hoped that there would be a built-in solution as Shadur pointed out. Thanks for your answer. –  Ulf Klose Oct 31 '11 at 12:29

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.