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?
rm "\-a" worked on my Mac, try again please
If you have GNU versions of rm
or unlink
, you can delete the file with:
rm -- -a
or
unlink -- -a
The --
tells it to stop processing command-line arguments and treat a leading -
as a literal.