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.

I've accidentally created a file named °. Now I'm having trouble deleting it with bash.

[/opt/etc/sudoers.d] # ls -l
-r--r-----    1 admin    administ       21 Feb  3 23:54 010-root
-rw-r--r--    1 admin    administ       20 Feb  3 23:50 °

Typing rm ° seems to only move the caret to the beginning of the line, i.e. no character is entered.

(For what it's worth I'm running bash 3.2.0 on a remote machine conntected with SSH using Mac OSX Terminal)

Any ideas?

share|improve this question
add comment

3 Answers

up vote 12 down vote accepted

How about?

rm -i ?

I think this should work...

share|improve this answer
1  
For further explanation, -i means "interactive". It will prompt you for each matching file before deleting it. –  bahamat Feb 5 '11 at 21:01
    
Great idea, but I had to replace ? with * to make it work. rm: cannot remove '?': No such file or directory. What am I missing? –  Oskar Feb 6 '11 at 12:42
2  
Perhaps your locale is wrong and so your shell sees the degree/ring symbol as two characters rather than one. Again, what does locale -a print? –  Mikel Feb 6 '11 at 20:15
    
Actually, the output of locale without -a would be better. –  Mikel Feb 6 '11 at 22:25
add comment

If there are a lot of matches to using a wildcard with rm like rm -i ?, you can always remove it by inode number instead:

ls -i
find . -inum <inode> -ok rm '{}' \;

Where <inode> is the inode number from ls -i, which lists all the inode numbers of the files in the current directory.

share|improve this answer
    
oh, this is cool. –  gabe. Feb 7 '11 at 22:28
add comment

The rm -i ? answer is fine.

This would also work:

rm [^a-z]

as would

rm [[:punct:]]

And as to why it's going back to the start of the line, how are you typing the ˚? Perhaps the input is being interpreted as Ctrl+A or some other shortcut that is used by the shell to go to the start of the line.

Is there a setting to set the encoding or character set to utf-8 in the terminal app? What does it print if you run locale inside the terminal session?


And how did you create the file? Maybe you can use a similar method to delete it?

share|improve this answer
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.