3

-p, --parents remove DIRECTORY and its ancestors; e.g., rmdir -p a/b/c' is similar tormdir a/b/c a/b a'

Yeah - I'm definitely not going to risk testing that out myself. ;)

InquilineKea
  • 6,262

1 Answers1

5

It does precicely what it says: it attempts to remove all the directories in the path that you give to it.

If you give it an absolute path, it will attempt to remove all the way back to root, so make sure you give it a relative path.

Shawn J. Goff
  • 46,081
  • Oh interesting - so there are concrete differences between absolute and relative paths.

    If it removes absolute paths, then will it also remove all of the descendants of each of its ancestors too? So if I gave it an absolute path, would it also remove /bin, /usr, /var, and /etc?

    – InquilineKea Oct 05 '11 at 20:01
  • 2
    Only if those directories are empty. rmdir will only remove empty directories. – James Sneeringer Oct 05 '11 at 20:18
  • @InquilineKea There isn't really anything special about using an absolute path, it's just going to treat root as one of the things you want to delete -- it's equivalent to running rmdir /a/b/c /a/b /a /. So even if /a/b/c actually existed, it would fail when it got to removing /, since other directories still exist (you'd get "Directory not empty") – Michael Mrozek Oct 05 '11 at 20:19