Delete empty directory:
rmdir directory_name
Delete multiple empty directories:
rmdir directory1 directory2 directory3
If the directory is not empty, an error will be thrown:
rmdir non_empty_directory
Remove a directory and its parent directory (if its parent directory is empty):
rmdir -p directory_name
Display the names of the directories to be deleted:
rmdir -v directory_name
Delete a directory even if it is not empty:
rmdir --ignore-fail-on-non-empty directory_name
With the rmdir --ignore-fail-on-non-empty command, the rmdir command will continue to execute the deletion operation even if the directory contains files or other subdirectories, without reporting an error. The purpose of this parameter is to ignore the check for non-empty directories and to delete the directory as much as possible.
However, it should be noted that if the directory contains non-empty files or subdirectories, the rmdir --ignore-fail-on-non-empty command will not be able to successfully delete these non-empty contents. Only when the directory is completely empty can the rmdir command successfully delete the directory.
Display help information and exit:
rmdir --help
Display version information and exit:
rmdir --version