Linux - Deleting a file containing special characters

October 2016

If the file you want to delete a character starting with "minus" (-), the rm command consider the following as part of the command line.
  • To remedy this, one solution is to precede the filename of the command "--", indicating rm that there are more options beyond this:
    • rm -- -name-of-file-to-be-deleted
  • A second solution is to escape the character "-" by preceding it with a backslash:
    • rm \-name-of-file-to-be-deleted
  • A final solution is to give the full path or relative path beginning with. / and having the filename in quotes:
    • rm ./"-name-of-file-to-be-deleted"

Thanks to Jeff for this tip.

Related :

This document entitled « Linux - Deleting a file containing special characters » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.