16

Somehow a file named -]???????q got created on my terminal. I tried rm -f "-]???????q" (in double quotes), but it did not get deleted. (Error:: rm: invalid option -- ]). How do I delete it?

djsmiley2kStaysInside
  • 6,643
  • 2
  • 31
  • 43
  • I had similar problem, in my case the problem was with samba implementation, just try to ssh to server and then remove it – Buksy Apr 05 '16 at 08:43

3 Answers3

27

For example, with:

rm -- '-]???????q'

Where -- means: "stop parsing options".

cYrus
  • 21,379
  • 8
  • 74
  • 79
  • Indeed, I ran into a similar problem not even thinking about - being a switch. I swear I spent like 2 hours trying to figure it out. – Jeff F. Jan 06 '11 at 17:11
  • Many applications use `--`, guess it's a kind of de facto standard due to the `getopt` function. – cYrus Jan 06 '11 at 18:42
14

You can either use the file name with rm or the inode number with find like :

rm -- -]???????q
# or
  -> ls -i                                                                                                                         
47984689 blah.ui  47983771 __init__.py  
47983773 testpy.e4p  47985161 Ui_blah.py

  -> find -inum 47983773                                                                                                           
./testpy.e4p

  -> find -maxdepth 1 -inum 47983773 -exec rm -i '{}' \;
#or
  -> find -maxdepth 1 -inum 47983773 -delete
OneOfOne
  • 947
  • 6
  • 13
1
rm ./"-]???????q"

Double quotes prevent the shell from expanding interrogation marks. For example, if you had another file called -]foobar.q:

$ touch ./"-]???????q" ./-]foobar.q
$ echo ./-]???????q
./-]foobar.q ./-]???????q
Termininja
  • 117
  • 1
  • 6
marco
  • 211
  • 1
  • 3