This question already has an answer here:

I have a file named #%2Amerge%2A#4984jjK#.

# starts a comment in bash. So how can I remove the file?


marked as duplicate by jasonwryan, don_crissti, Kusalananda, Jeff Schaller, Gilles bash May 2 '17 at 22:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


By escaping the octothorpe(s):

rm -- \#badly-named-file\#1

Or by using strong (or weak) quotes:

rm -- '#badly-named-file#1'

Or by using wildcards (dangerous potentially; test with e. g. ls first):

rm -- ?badly-named-file?1
  • 1
    ... or quoting the filename. – Kusalananda May 2 '17 at 21:06
  • or just rm ./#badly-named-file#1 – hschou May 2 '17 at 22:16
  • This would do the needful: rm \#* – user218374 May 3 '17 at 7:11
  • Using the * wildcard with rm is potentially dangerous and should only be done will all due caution, deliberation, and necessity. – DopeGhoti May 3 '17 at 17:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.