Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I accidently created a file named ??q:q and i can't remove it.

rm '??q:q' or rm '\?\?q\:q' (To escape the ?) says No such file or directory

Another interesting thing: in ls it shows the name as ??q:q. But when I type rm <tab><tab> is says ^?^?q:q (I tried to remove it with this name, too)

share|improve this question
Just tested this - but rm \?\?q\:q works... (without the quotes) – Wilf Dec 11 '13 at 10:41
I think the problem is the way I created the file, which I sadly can't remember. When I type rm <tab><tab> the filename is different. If i just create a File with ne name ??q:q, a simple rm` will work – 0xAffe Dec 11 '13 at 10:46
what does ls -l show for the file? – Wilf Dec 11 '13 at 10:50
it shows ??q:q – 0xAffe Dec 11 '13 at 10:51
For the permissions - like -rw-rw-r--. 1 wilf wilf 0 Dec 11 10:54 ??q:q – Wilf Dec 11 '13 at 10:54

rm has the -- option, which makes rm treat everything behind those two dashes as the filename.

Thus, using

rm -- ??q:q

should remove the file.

Tested using bash 4.2.45 on Ubuntu 13.10.

share|improve this answer
Note: this command will also remove a file named XXq:q. To prevent that, quote it. I guess that the file is not really named (question mark)(question mark)q:q, but that that the filename is invalid for the configured character set. In that case, wildcards may work (try it first with ls -ld *q:q!), and otherwise use the find inode trick from falconer. – Lekensteyn Dec 11 '13 at 11:17

If drc's answer didn't work then try deleting it by the inode number:

  1. Find out the inode number of the file with ls -i, eg. 123456

  2. Remove:

    find . -inum 123456 -exec rm -i {} \;
share|improve this answer
It is safer if it prints back the filename what we want to delete. – falconer Dec 11 '13 at 11:02
@AvinashRaj The filename that appears visually does not have to be the real filename. For fun, create a file consisting of all bytes 1 to 256 (excluding the / because it is a directory separator): touch "$(python2 -c 'print("".join(chr(i) if i!=ord("/") else "" for i in range(1,256)))')" – Lekensteyn Dec 11 '13 at 11:22
@Lekensteyn that's my guess too that these aren't real question marks. – falconer Dec 11 '13 at 11:26

Your Answer


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.