Learn about Linux commands today: the RmDir command. RmDir is a commonly used command, the function of which is to delete an empty directory before a directory is deleted must be empty. (Note that the Rm-r dir command can be used instead of rmdir, but there is a lot of danger.) You must also have write access to the parent directory when you delete a directory.
1. Command format:
rmdir [Options] ... Directory...
2. Command function:
This command removes one or more subdirectory entries from a directory and must also have write access to the parent directory when a directory is deleted.
3. Command parameters:
-p recursively deletes the directory dirname, which is also deleted when its parent directory is empty after the subdirectory is deleted. If the entire path is deleted or a partial path is reserved for some reason, the system displays the appropriate information on the standard output.
-V,--verbose show instruction execution process
4. Command instance:
Instance one: RmDir cannot delete a non-empty directory
Command:
RmDir doc
Output:
[Email protected] scf]# tree
.
|--bin
|--doc
| |--Info
| '--product
|--Lib
|--logs
| |--Info
| '--product
'--Service
'--Deploy
|--Info
'--product
Directories, 0 files
[Email protected] scf]# rmdir doc
Rmdir:doc: Directory Non-empty
[Email protected] scf]# rmdir doc/info
[Email protected] scf]# rmdir doc/product
[Email protected] scf]# tree
.
|--bin
|--doc
|--Lib
|--logs
| |--Info
| '--product
'--Service
'--Deploy
|--Info
'--product
Ten directories, 0 files
Description
RmDir Directory name command cannot delete a non-empty directory directly
Instance 2:rmdir-p when a subdirectory is deleted and makes it an empty directory, it is deleted by the way
Command:
Rmdir-p logs
Output:
[Email protected] scf]# tree
.
|--bin
|--doc
|--Lib
|--logs
| '--product
'--Service
'--Deploy
|--Info
'--product
Ten directories, 0 files
[Email protected] scf]# rmdir-p logs
Rmdir:logs: Directory Non-empty
[Email protected] scf]# tree
.
|--bin
|--doc
|--Lib
|--logs
| '--product
'--Service
'--Deploy
|--Info
'--product
9 Directories, 0 files
[Email protected] scf]# rmdir-p logs/product
[Email protected] scf]# tree
.
|--bin
|--doc
|--Lib
'--Service
'--Deploy
|--Info
'--product
7 directories, 0 files
Linux command--6 rmdir (GO)