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.

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
add comment

2 Answers 2

The regular expression * stands for zero or arbitrary many. So you told apt-get to remove anything which starts with 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
7  
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 at 17:06
add comment

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

http://ccrma.stanford.edu/planetccrma/man/man8/apt-cache.8.html

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
add comment

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.