1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-02 22:58:01 +00:00
Files
til/unix/remove-a-directory-called-dash-p.md
2022-04-11 14:43:00 -05:00

804 B
Raw Permalink Blame History

Remove A Directory Called -p

I accidentally created a directory from the terminal called -p. It is sitting there next to other directories like app and public. I need to get rid of it. The rmdir command is the best way to do that.

$ rmdir -p
usage: rmdir [-p] directory ...

Not so fast. -p is also a valid flag for the rmdir command. It doesn't know that I mean it as the name of the directory. So instead, I am missing a required argument to rmdir the directory.

To get this to work, I need to tell rmdir that I intend -p as the name of the directory to remove.

$ rmdir -- -p

The -- is a command-line convention. It tells the command that anything after the -- is not a flag, but instead an argument. This time the -p directory will be removed.