user1701545
user1701545

Reputation: 6220

Delete files with backslash in linux

I accidentally created a file which name is a backslash \:

>ls -l
total 0
-rw-rw---- 1 user group  0 Jul  3 21:34 \

How do I delete it?

Upvotes: 3

Views: 7477

Answers (1)

ruakh
ruakh

Reputation: 183582

In order to pass a backslash in an argument to a command, you need to "quote" or "escape" it, which you can do either by wrapping it with single-quotes:

rm '\'

or by prefixing it with another backslash:

rm \\

(The same sort of thing is needed if you, say, have a file named *. To delete it, you would write rm '*' or rm \* or rm "*". And similarly for most other special characters.)

Upvotes: 13

Related Questions