Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Last night I was trying to burn CDs. Being annoyed with k3b and choosing to use brasero instead, I went to remove k3b. I typed in:

sudo apt-get remove k3b

I hit tab twice and saw that I had both k3b and k3b-data on my system. Assuming that I wouldn't need k3b-data on my system without k3b, I wanted to remove it as well so I typed in:

sudo apt-get remove k3b*

Unfortunately I hit Y to confirm without looking. It uninstalled a whole lot more than k3b and k3b-data. It uninstalled packages which did not fit my "k3b*" regex. For example: transmission and network-manager

I'm fairly certain that I didn't have a space between k3b and * but I don't know why else it would remove all that it did. Is there something about apt-get that I'm misunderstanding?

share|improve this question

The regular expression * stands for zero or arbitrary many. So you told apt-get to remove anything which contains k3 followed by any number of b, so basically everything which contains k3. If I try your command on my system it wants to remove 58 packages.

sudo apt-get remove -s k3b*
Package k3b is not installed, so not removed
Package k3b-data is not installed, so not removed
Package k3b-dbg is not installed, so not removed
Package libcanberra-gtk3-0 is not installed, so not removed
Package libcanberra-gtk3-0-dbg is not installed, so not removed
Package libcanberra-gtk3-dev is not installed, so not removed
The following packages will be REMOVED:
  appmenu-gtk ardour audacity brasero brasero-cdrkit firefox-globalmenu
  gconf-editor gir1.2-appindicator-0.1 gnome-applets gnome-control-center
0 upgraded, 2 newly installed, 58 to remove and 0 not upgraded.
share|improve this answer
ugh! I've been stuck working on these darn windows machines (where * just means "and anything after") for way too long! – Steve Goykovich Nov 2 '12 at 14:26
The * does work as a wildcard for bash like in DOS, but some commands like apt-get expect a regex. When you type sudo apt-get remove -s k3b*, bash will first look for any files in your current directory that begin with k3b. If it finds any, it will replace that argument with those filenames. If not, it will pass k3b* directly to apt-get, which will interpret it as a regex. If you don't want bash to interpret the asterisk as a wildcard first (which you probably don't), surround the argument with single quotes, like this: sudo apt-get remove -s 'k3b*' – Flimm Nov 12 '12 at 14:49
So the intended command would have been sudo apt-get remove -s 'k3b.*'. Just stumbled upon this answer and find it really important to know. IMHO this is quite unexpected and I would quite mark it as a "unexpected behavior" bug of apt-get... you normally expect a "glob" meaning and not a "regexp" meaning if not specified. Thanks anyway and +1! – Rmano Mar 10 '14 at 17:06
And for those like me who didn't know: the -s option means "simulation". It tells apt-get not to perform the operation, but simply to inform you of what would happen without the -s option. – Boris Aug 19 '14 at 18:26
I think that your use of single quotes to create globbing does NOT work, at least in puppet. And that is unexpected. In 'find' program, if I write find / -iname 'project*' I will find everything that begins with project, not something that has 'project' in it and anything after it. As proof regarding puppet, notice how my results say 'regex', and the results prove it? – Dennis Jun 26 '15 at 5:45

To complete and summarize the info provided by qbi and Flimm:

  • You need .* to match any character, any number of times
  • You need ^ to match the start of the string
  • You need to quote the regex to prevent bash from interpreting * as a wildcard

So the command you want is sudo apt-get remove '^k3b.*'

share|improve this answer

You more then likely remove a lib that had k3b in it that those programs depended on.

In short you may never know. I recommend not using a wildcard to remove things and to read things when prompted (sorry).

Also with out the -n regex searches use all fields and not just names

also qbi is correct your regex is flawed from the get-go

share|improve this answer
One other thing, In cases like yours (k3b and k3b data) just apt-get uninstall k3b. Apt will then inform you if you have things installed that you no longer need, and what you need to do to remove them. – coteyr Nov 2 '12 at 14:21
wow! I never would have expected it to search within descriptions too! yeah, this is definitely something I'll never do again! (and I'll be sure to read things next time :P) – Steve Goykovich Nov 2 '12 at 14:28
The link is broken, would you mind clarifying how to use the -n? – Seanny123 Sep 17 '13 at 8:39
-n means only search in the names field. – coteyr Sep 17 '13 at 13:09
After trying, the -n option is not recognized by apt-get remove, only by apt-get cache. It seems that actually, apt-get remove only looks for package names, not descriptions. – Boris Aug 19 '14 at 18:45

Your Answer


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.