RMDIR(1) User Commands RMDIR(1)

NAME


rmdir - remove directories

SYNOPSIS


/usr/bin/rmdir [-ps] dirname

ksh93
/usr/bin/rmdir [-eps] dirname ...

DESCRIPTION


The rmdir utility removes the directory entry specified by each dirname
operand, which must refer to an empty directory.

Directories are processed in the order specified. If a directory and a
subdirectory of that directory are specified in a single invocation of
rmdir, the subdirectory must be specified before the parent directory
so that the parent directory is empty when rmdir tries to remove it.

ksh93
The rmdir built-in in ksh93 is associated with the /bin and /usr/bin
paths. It is invoked when rmdir is executed without a pathname prefix
and the pathname search finds a /bin/rmdir or /usr/bin/rmdir
executable.

OPTIONS


The following options are supported for both /usr/bin/rmdir and ksh93
rmdir:

-p Allows users to remove the directory dirname and its parent
directories which become empty. A message is printed to
standard error if all or part of the path could not be
removed.

-s Suppresses the message printed on the standard error when
-p is in effect.

ksh93
The following options are supported for the rmdir built-in for ksh93:

-e, --ignore-fail-on-non-empty
Ignore each non-empty directory failure.

--parents Long option for -p.

--suppress Long option for -s.

OPERANDS


The following operands are supported:

dirname Specifies the pathname of an empty directory to be
removed.

USAGE


See largefile(7) for the description of the behavior of rmdir when
encountering files greater than or equal to 2 Gbyte (2^31 bytes).

EXIT STATUS


The following exit values are returned:

0 All the existing named directory entries were removed.

>0 An error occurred.

EXAMPLES


Example 1 Removing Empty Directories

If a directory a in the current directory is empty, except that it
contains a directory b, and a/b is empty except that it contains a
directory c, the following command removes all three directories:

example% rmdir -p a/b/c

INTERFACE STABILITY


Committed

ksh93 built-in binding to /bin and /usr/bin is Volatile. The built-in
interfaces are Uncommitted.

SEE ALSO


ksh93(1), rm(1), unlink(2), attributes(7), largefile(7), standards(7)

illumos March 28, 2026 illumos