rmdir — Remove a directory

Format

rmdir [–p] directory …

Description

rmdir removes each requested directory. Each directory must be empty for rmdir to be successful.

Options

–p
Removes all intermediate components. For example:
rmdir -p abc/def/ghi
is equivalent to:
rmdir abc/def/ghi
rmdir abc/def
rmdir abc

Localization

rmdir uses the following localization environment variables:
  • LANG
  • LC_ALL
  • LC_CTYPE
  • LC_MESSAGES
  • NLSPATH

See Localization for more information.

Exit values

0
Successful completion
1
Failure to remove the directory. For example, the object is not a directory, the directory still contains files or subdirectories, or the user is not authorized.
2
Failure because either the command-line option was incorrect or a directory name was not specified.

Messages

Possible error messages include:
Nonempty directory
Files or other directories are found under the directory to be removed. Use rm –r to remove the directory.
No such directory
The requested directory does not exist or is otherwise inaccessible.

Portability

POSIX.2, X/Open Portability Guide, UNIX systems.

Related information

mkdir, rm