Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

Accidentally, i have got this directory created in my home,

drwxr-xr-x  2 ubuntu ubuntu 4.0K 2012-09-06 07:27  :q!/

I want to remove this somehow. I have tried using escape characters in double quotes but no luck. Is there any clean way to remove it ?

share|improve this question
    
maybe you should stop using vim so much :) –  MattDMo Jun 18 '13 at 13:41
2  
I can delete it using rmdir :q! on my MacOSX using bash and zsh and without any escaping or quoting. I don't understand where you're failing. Can you show us the commands you're running and the error messages you're getting? –  rahmu Jun 18 '13 at 13:43
    
ubuntu@gslabrails:~$ rmdir " :q!" >>-bash: !": event not found –  Aashish P Jun 18 '13 at 13:50
    
That may be a history expansion problem. rmdir :q\! should work then. What is the output of echo $-? –  Hauke Laging Jun 18 '13 at 13:50
    
ubuntu@gslabrails:~$ echo $- >>himBH –  Aashish P Jun 18 '13 at 13:52
show 1 more comment

marked as duplicate by Michael Mrozek Jun 18 '13 at 15:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3 Answers

up vote 5 down vote accepted

This is a history expansion problem. rmdir \ :q\! should work, rmdir ' :q!', rmdir " ":q!, and rmdir " ":q!, too.

share|improve this answer
    
Yeah, you are correct. –  Aashish P Jun 18 '13 at 13:55
add comment

I used the context menu in my file browser to delete a folder with that name. Unless you don't have any GUI on your system, that should work. No history expansion problem.

share|improve this answer
    
I love this: the Gordian knot approach –  evilsoup Jun 18 '13 at 19:52
    
Actually, I just prefer GUI anyway. I'm so unhackerlike :P –  Wutaz Jun 19 '13 at 3:36
add comment

It is always helpful to use ./ followed by the filename completion feature of bash. It will automatically insert the required escape characters.

share|improve this answer
add comment

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