0

For example, when I want to remove Xfce, I did this:

 aptitude search xfce | grep ^i

id  gtk2-engines-xfce               - GTK+-2.0 theme engine for Xfce            
id  libxfce4ui-common               - common files for libxfce4ui               
id  libxfce4util-common             - common files for libxfce4util             

I want to get the second column and pass them to aptitude remove. Is there a way to do it?

1 Answer 1

0

apt-get supports regular expressions. Just include a ., * or ? in the package name to make it an expression:

apt-get remove 'xfce.'

From man apt-get:

If no package matches the given expression and the expression
contains one of '.', '?' or '*' then it is assumed to be a POSIX
regular expression, and it is applied to all package names in the
database. Any matches are then installed (or removed). Note that
matching is done by substring so 'lo.*' matches 'how-lo' and
'lowest'. If this is undesired, anchor the regular expression with
a '^' or '$' character, or create a more specific regular
expression.
4
  • Thank you. This works when the string is at the begining. I have to run apt-get remove '.xfce' again to clean all of them up. Does aptitude support regular expressions?
    – Nick
    Dec 4, 2014 at 0:21
  • @Nick Tried .*xfce.*? With aptitude the syntax is different, try aptitude remove '~xfce'.
    – muru
    Dec 4, 2014 at 0:26
  • I've removed all the xfce packages. I think .*xfce.* would work. Thank you. The aptitude syntax is weird. I'll search for its documentation to learn the usage. By the way, which do you prefer, apt-get or aptitude?
    – Nick
    Dec 4, 2014 at 2:02
  • @Nick Since aptitude is not installed by default, apt-get (or apt, now). But there are some things for which aptitude is the right tool.
    – muru
    Dec 4, 2014 at 6:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .