Forrest logo
back to the rmdir tool

rmdir:tldr:69c26

rmdir: Remove specific nested directories recursively.
$ rmdir -p ${path-to-directory1 path-to-directory2 ---}
try on your machine

The rmdir -p command is used to remove directories including their parent directories. Here is the breakdown of the command:

  • rmdir is the command to remove directories. It is short for "remove directory".
  • -p is an option or flag that tells the rmdir command to remove parent directories as well. If any of the parent directories are empty after removing the specified directories, they will also be removed.
  • ${path-to-directory1 path-to-directory2 ---} represents the list of directories you want to remove, separated by spaces. You need to replace path-to-directory1 with the actual path to the first directory you want to delete, path-to-directory2 with the path to the second directory, and so on.

For example, if you want to remove two directories: /parent/child1 and /parent/child2, the command would be:

rmdir -p /parent/child1 /parent/child2

Executing this command would remove the child1 and child2 directories along with their parent directory parent, provided that all the directories are empty after their removal.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the rmdir tool