8

I don't know how I've done this but I've created somehow a folder named "-p". Now I'm trying to delete it but my buntu is thinking I'm passing -p as a paremeter.

What can I do?

Ubuntu Server 15.

Zanna
  • 72,312
Magno C
  • 202

2 Answers2

12

You can use -- to tell rm (and many other commands including many shell built-ins) not to interpret any further input as command parameters, so that -p can be interpreted correctly as an argument instead of an "unrecognised option"

rm -- -p

(This is also a good safety measure when globbing. You might have accidentally created a file called -rf...)

Zanna
  • 72,312
6

the proper way in this case is :

rm ./-p

-- may work with some commands, and fail with others. it is not bash that interprets it, but each command separately (and some may not recognise -- as the end of options) (especially true if you ever use non gnu commands... for example if you work on some other OSs).

Taking the habit of saying ./somefileorglob instead of just somefileorglob is a good habit, in general.