I'm trying to remove a file I made by mistake using --exclude with tar. I ended up making a tar file named --exclude=*.tar Now I want to delete it but I'd like to rename it first. How do I escape it correctly?

marked as duplicate by Gilles, Joseph R., slm, Renan, jasonwryan Nov 17 '13 at 2:38

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.


There are two straightforward ways to do this using just rm:

rm -- --exclude=*.tar


rm ./--exclude=*.tar 

I just used mv ./--exclude=*.tar deleteThisFile and that worked fine.

  • I think the only things you ever need to escape are spaces (if you don't quote) or quotes (if you do quote). – goldilocks Nov 15 '13 at 19:10

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