rmdir - remove directories
rmdir [-p] dir...
The rmdir utility will remove the directory entry specified by each dir operand, which must refer to an empty directory.
Directories will be processed in the order specified. If a directory and a subdirectory of that directory are specified in a single invocation of the rmdir utility, the subdirectory must be specified before the parent directory so that the parent directory will be empty when the rmdir utility tries to remove it.
The rmdir utility supports the XBD specification, Utility Syntax Guidelines .
The following option is supported:
- Remove all directories in a pathname. For each dir operand:
- The directory entry it names will be removed.
- If the dir operand includes more than one pathname component, effects equivalent to the following command will occur:
rmdir -p $(dirname dir)
The following operand is supported:
- A pathname of an empty directory to be removed.
The following environment variables affect the execution of rmdir:
- Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
- If set to a non-empty string value, override the values of all the other internationalisation variables.
- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).
- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
- Determine the location of message catalogues for the processing of LC_MESSAGES .
Used only for diagnostic messages.
The following exit values are returned:
- Each directory entry specified by a dir operand was removed successfully.
- An error occurred.
The definition of an empty directory is one that contains, at most, directory entries for dot and dot-dot.
If a directory a in the current directory is empty except it contains a directory b and a/b is empty except it contains a directory c:will remove all three directories.
rmdir -p a/b/c
rm, the XSH specification description of remove(), rmdir(), unlink().