Search code examples
linuxcommandrm

how to delete a file started with '-'


How can I delete a file whose name started with '-'?

For example, if I have a file named -a and I delete it with:

    rm -a

I will get:

    rm: invalid option -- 'a'
    Try 'rm --help' for more information.

So how can I do it?


Solution

  • You may try like this:

    rm ./-foo
    rm ./-filename
    rm -- -foo