How to delete file with this name on linux: -]???????q [duplicate]

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?


Solution 1:

For example, with:

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

Where -- means: "stop parsing options".

Solution 2:

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

Solution 3:

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