How would you delete a folder called * in / from bash?

Let's say i had a folder named * under /. I know that common commands like rm -rf * won't work. Any help?


use this short command:

rm /\*

You can single-quote arguments to prevent processing by the shell.

rm -r '/*'

Test it safely using ls (in folders containing files):

$ ls '*'
ls: *: No such file or directory

In this case, double quotes would work as well, but if there'd be an $ involved, they wouldn't, as the shell would assume it's a variable:

$ ls "foo$bar"
ls: foo: No such file or directory
$ ls 'foo$bar'
ls: foo$bar: No such file or directory

For GNU rm, you can also add -- before the file name arguments to prevent them from getting parsed as arguments. This'll allow you to delete files named -rf without problems.