Introduction to Commands:
The rmdir command is used to delete an empty directory and an error occurs if the directory is not empty. After you can use RM to delete a file in a directory, use RmDir to delete the directory. You can also use RM-RF instead of the rmdir command. This is a very simple command.
Command syntax:
rmdir [OPTION] ... DIRECTORY ...
Command parameters:
Parameters |
Long parameters |
Description |
|
--ignore-fail-on-non-empty |
Ignore any errors caused by data files in the directory |
-P |
--parents |
Recursively delete directory |
-V |
--verbose |
Show detailed information about command execution |
|
--help |
Show Commands online Help |
|
--version |
Display Command version information |
Use examples:
1: View Help for the rmdir command
[Root@db-server ~]# rmdir--helpusage:rmdir [OPTION] ... DIRECTORY ... Remove the DIRECTORY (ies), if they are empty. --ignore-fail-on-non-empty Ignore each failure this is solely because a directory is non-empty-p,--parents Remove DIRECT Ory and its ancestors. e.g., ' rmdir-p a/b/c ' is similar to ' rmdir a/b/c A/b '. -V,--verbose output a diagnostic for every directory processed--HELP display it help and exit--version output version Information and exit bugs to <bug-coreutils@gnu.org>.
You can also use the following command to view RmDir Document information
[Root@db-server ~]# Mans RmDir
2: Use RmDir to delete empty directories
If the directory is not empty, an error message appears.
[Root@db-server ~]# ls/root/kerry/file1[root@db-server ~]# rmdir kerryrmdir:kerry:Directory not empty[root@db-server ~ ]# Rm-f/root/kerry/*[root@db-server ~]# rmdir Kerry
3: Show details of command execution
[Root@db-server ~]# mkdir test1 test2 test3[root@db-server ~]# lsanaconda-ks.cfg Desktop install.log install.log.syslog t Est1 test2 test3[root@db-server ~]# rmdir-v, test1 test2 directory, test3rmdir:removing directory, t Est2rmdir:removing directory, Test3
4: Delete the directory recursively, as shown below, first create the directory Kerry, create an empty directory TMP under the Kerry directory, and then empty directory test
[Root@db-server ~]# mkdir-p kerry/tmp/test[root@db-server ~]# Tree kerrykerry '--tmp '--Test 2 directories, 0 files[root @DB-server ~]# rmdir-p kerry/tmp/test
5: Ignore any errors caused by data files in the directory
[Root@db-server ~]# mkdir Kerry [root@db-server ~]# CD Kerry [root@db-server kerry]# touch file1 [Root@db-server Kerry] # CD ... [Root@db-server ~]# rmdir--ignore-fail-on-non-empty kerry/