RMDIR(1) User Commands RMDIR(1)

rmdirremove directories

/usr/bin/rmdir [-ps] dirname

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

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.

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.

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

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.
Suppresses the message printed on the standard error when -p is in effect.

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

, --ignore-fail-on-non-empty
Ignore each non-empty directory failure.
Long option for -p.
Long option for -s.

The following operands are supported:

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

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

The following exit values are returned:

All the existing named directory entries were removed.
An error occurred.

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

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

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

March 28, 2026 OmniOS