0
Thanks

A few words of thanks would be greatly appreciated.

Linux - Deleting a file containing special characters



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.
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Published by . Latest update on by jak58.

This document, titled "Linux - Deleting a file containing special characters," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).

0 Comments