Remove directories (POSIX)
rmdir [-p] dir...
QNX Neutrino, Microsoft Windows
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.