I've somehow created a file called \ in a directory (yes, backslash character). I've tried all sorts of sed, find and grep fu but I just can't delete it! I know I could just delete the directory, but is there a more interesting way to fix this?

[root@abcdef ~]# touch \\
[root@abcdef ~]# ls -l \\
-rw-r--r--. 1 root root 0 Jul  6 09:29 \
[root@abcdef ~]# rm -f \\
[root@abcdef ~]#

ps. If you are running windows, you have corrupted NTFS.

  • hahaha, if you need to make it hidden make it .\\ - this way you can have folder like .\\folder\\ or just \\folder\\ – Andrew Smith Jul 6 '12 at 16:49
  • Why not just use rm \\ ? In comparison, rm -f \\ has the look of something that is very dangerous (even if technically it is not dangerous). – foghorn May 19 '17 at 21:35

Can you be sure that that really is just a backslash?

Thought the following rather amusing session may prove useful to others in a similarly dismayed state as I just was:

[root@x y]# ls -la . | grep -F '\'
-rw-r--r--  1 root root     452 Jun 17 10:28 \
[root@x y]# rm \\
rm: cannot remove '\': No such file or directory
[root@x y]# rm '\'
rm: cannot remove '\': No such file or directory
[root@x y]# for f in *; do echo "#$f#"; done;
# #
[root@x y]# mv ' ' x
[root@x y]# vim x

FYI, the content appeared to be a dump of awk environment variables.. currently no idea how it got there!


you can delete the '\' file name by issuing the command - rm \\

it will del


If you are not sure to master the command line for this operation, I suggest installing Midnight Commander, or mc, see https://midnight-commander.org/ (I am not affiliated with it, just a happy user of it). It is packaged in various Linux distributions.

It is a small utility showing a graphical display (but still just with a terminal, no X/Window) of your files, with all standard operations available, like delete.

It can simplify things, as it will be quicker just to move to the file with the arrows and press F8 (if memory serves) to delete the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.