Reputation: 1345
I've accidentally created files with names that won't allow me to delete them:
-d
--header
Doing the following has no effect:
rm -f '-d'
rm -f '--header'
unlink ('-d');
unlink ('--archive');
Unlink gives an error:
unlink: invalid option -- 'd'
Try 'unlink --help' for more information.
How can I get rid of these files?
Upvotes: 1
Views: 93
Reputation: 44264
Use --
to tell BASH that the command options has ended, then, all other parameters are treated as positional parameters so they wont be interpreted by rm
;
rm -- --header
rm -- --d
More on --
: What does “--” (double-dash) mean?
Upvotes: 2