Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have some weird file in my home directory which name is \e[m. I am using Linux. How can I delete it because I tried rm but it says no such file or directory found?

share|improve this question

migrated from stackoverflow.com Jun 10 '13 at 14:19

This question came from our site for professional and enthusiast programmers.

add comment

5 Answers

If none of the other answers posted here are working, you can always try removing a file based on its inode.

To do that:

  1. Find the file's inode by doing ls -i. Let's suppose the inode number is 123456 for \e[m.
  2. Delete the file based on its inode number: run either find -inum 123456 -delete or find -inum 123456 -exec rm {} \;.
share|improve this answer
2  
Upvoted, but note -delete is probably better than -exec rm {} \;. –  kampu Jun 10 '13 at 12:31
    
You're right. Thanks. I've updated the post to reflect your suggestion. –  cmt Jun 10 '13 at 12:44
    
@kampu: -delete is not required by the POSIX standard for find, so it may not be available in all implementations of find. –  chepner Jun 10 '13 at 18:28
add comment

Honestly, the easiest thing would be to use a file manager that by passes any shell-globing.

Using a shell, I'd try using the shell completion system (assuming you are using a shell with such). Like rm [TAB], if your shell gives you a menu and allows you to pick from the menu or cycle through it, you should be able to get completion that is text representation that your shell will recognize.

share|improve this answer
add comment

Possible ways:

rm \\e\[m

or

rm '\e[m'

or

rm "\\e[m"
share|improve this answer
    
doesn't work... still says no such file or directory –  CuriousGuy Jun 10 '13 at 11:19
    
You may have an unprintable character in the file name then. You could try using wild cards such as rm '\e'* –  Dave Newman Jun 10 '13 at 11:22
    
rm "$HOME"'/\e[m'? –  cmt Jun 10 '13 at 11:22
    
Maybe the actual name of the file is not \e[m? –  Adam Siemion Jun 10 '13 at 11:22
add comment

If \e is an escape character (ASCII code 27), and you are using the Bash shell, you could try:

rm $'\e[m'
share|improve this answer
add comment

You can use glob expansion. try ls *[[]m, and if that only returns this file, then you can safely do rm *[[]m.

If the offending file is not listed with the above ls command, it certainly contains an escape and the 'm' is not actually a literal m (and/or the [ is not a literal [)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.