How to delete a file whose name begins with a “-” character?

The easiest way to do the job is something as follows:

rm ./-file_to_delete

Another approach that is useful for commands that use getopt to parse the arguments is shown next:

rm — -file_to_delete

This tells the command rm (or whatever command that uses getopt) that anything after “–” is not an option.

Leave a Reply

You must be logged in to post a comment.