Remove directories (POSIX)
rmdir [-p] dir...
All supported hosts.
- Remove the entire directory path (consisting only of directories that are empty except for the named pathname components) of the directories specified on the command line. (See example.)
- The pathname of an empty directory to be removed.
The rmdir utility removes the directory specified by each dir operand, provided the directory is empty.
The rmdir utility processes directories in the order they're specified on the command line. If you specify a parent directory, you should specify its subdirectory before the parent directory. That way, the parent directory will be empty when the rmdir utility tries to remove it.
Remove the subdirectory oldfiles from the /home/fred directory:
Remove the directory path dir1/dir2/dir3:
rmdir -p dir1/dir2/dir3
For this command, rmdir first removes dir1/dir2/dir3. If this is successful, it then removes dir1/dir2. If this is also successful, it removes dir1.
- Each directory specified by a dir operand referred to an empty directory and was removed successfully.
- An error occurred.