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.

So, on a CentOS box, I accidentally executed :w<Down> in a vim editor, with "<Down>" being literally pressing the down arrow key on the keyboard (rendered onscreen as "<Down>"), and now I have a file named "<Down>" which I can't seem to get rid of; running "rm <Down>" (literally spelling out "less-than, D, o, w, n, greater-than") gives a syntax error.

How can I get rid of this file with the funky name?

share|improve this question

5 Answers 5

up vote 12 down vote accepted

Use singlequotes to keep the control characters from being processed:

rm -f '<Down>'
share|improve this answer
    
We have all ran into this issue at some point when we first started out with linux. I for the longest time had trouble editing files with spaces in the name until I realized I could just put quotes around it. –  The Digital Ninja Jul 15 '10 at 19:33

The easiest way I found to deal with all cases of escaping is using a scripting language:

$ cd /tmp/test/
$ ls
<Down>
$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.unlink('<Down>')
>>> quit()
$ ls
share|improve this answer

type rm <D and then press TAB , it will show suggestions, for the name of the desired file..

share|improve this answer
1  
I deleted your duplicate answer - 'interesting' choice of icon by the way... –  Chopper3 Jul 16 '10 at 14:56

As an alternate solution:

$ ls -il .
total 0
1439039 -rw-r--r-- 1 medina foo 0 2010-07-15 16:48 ?????

# http://www.gnu.org/software/findutils/manual/html_mono/find.html#Deleting-Files
$ find . -inum 1439039 -delete
share|improve this answer

Use \ to escape special characters. In this case, you would use

rm \<Down\>
share|improve this answer

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.