RMDIR(1) General Commands Manual RMDIR(1)

rmdirremove directories

rmdir [-p] dir ...

The rmdir utility shall remove the directory entry specified by each dir operand, which shall refer to an empty directory. Directories shall 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 shall 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 shall conform to the utility argument syntax guidelines described in 2.10.2. The following option shall be supported by the implementation:

Remove all directories in a pathname. For each dir operand:

  1. The directory entry it names shall be removed.
  2. If the dir operand includes more than one pathname component, effects equivalent to the following command shall occur: rmdir −p $(dirname dir)

The following operand shall be supported by the implementation:

dir

A pathname of an empty directory to be removed.

None.

None.

The following environment variables shall affect the execution of rmdir:

This variable shall determine the locale to use for the locale categories when both LC_ALL and the corresponding environment variable (beginning with LC_ ) do not specify a locale. See 2.6.

This variable shall determine the locale to be used to override any values for locale categories specified by the settings of LANG or any environment variables beginning with LC_.

This variable shall determine the locale for the interpretation of sequences of bytes of text data as characters (e.g., single- versus multibyte characters in arguments).

This variable shall determine the language in which messages should be written.

Default.

None.

Used only for diagnostic messages.

None.

None.

The rmdir utility shall exit with one of the following values:

Each directory entry specified by a dir operand was removed successfully.

An error occurred.

Default.

On historical System V systems, the −p option also caused a message to be written to the standard output. The message indicated whether the whole path was removed or part of the path remains for some reason. The Standard Error subclause requires this diagnostic when the entire path specified by a dir operand is not removed, but does not allow the status message reporting success to be written as a diagnostic. 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, rmdir -p a/b/c will remove all three directories. The rmdir utility on System V also included an −s option that suppressed the informational message output by the −p option. This option has been omitted because the informational message is not specified by . 2.

September 1991 posix.fail