Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I delete a file named -p in bash? Trying rm "-p" complains that -p is not a valid argument.

share|improve this question
You write "delete a file" yet the title says "delete a folder". Please make the question consistent so that it gets properly indexed. – sam hocevar Mar 20 '11 at 3:22
up vote 23 down vote accepted

Most GNU tools support -- to terminate the options.

rm -- -p
rm ./-p
share|improve this answer
Not just GNU tools, but all POSIX-compliant tools, and in practice all non-antique unix tools. – Gilles Sep 8 '11 at 21:58

The NOTE section in the man page for rm has something to say exactly about this. Apart from what Ignacio Vazquez-Abrams has mentioned in their answer, one other way of removing such files, as mentioned in the man page, is by using an absolute path reference, such as: rm /home/user/-p.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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