Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete files with backslash in linux

Tags:

linux

shell

rm

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?

like image 643
user1701545 Avatar asked Jun 07 '26 20:06

user1701545


1 Answers

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.)

like image 182
ruakh Avatar answered Jun 10 '26 06:06

ruakh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!