Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

rm files starting with "?" on linux

I have multiple files starting with "?" that were mistakenly created. For a file "?" (a single character, no extension), I tried:rm ? rm \? rm ./? rm '?' (and combination of these).

All of them return "rm: cannot remove ‘?’: No such file or directory".

Please teach me how to delete the file.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

[UPDATE]

The files appear as "?" by ls. However with -b. The file named ? turns out to be \274 and the other file ??Vk???8HU?^q???M????P??6?FeF?$? turns out to be \305\377Vk\21.... Now I can remove them. I appreciate the help from the community.

>Solution :

rm '?' should do the trick.
? Is a glob pattern, matching a single character. So rm ? and rm ./? would remove files with any single character as their name.

But, you potentially have a more complex name (which can’t be displayed).
You can show the special characters in C-Style escaping using ls -b.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading