rmdir [ -p ] [ -s ]
The rmdir command removes the entries for one or more
sub-directories from a directory. A directory must be empty before
it can be removed. (Note that the rm -r dir
command is a more dangerous alternative to rmdir.) If the
parent directory has the ``sticky'' bit set, removal occurs only if
one of the following is true:
rmdir takes the following options:
the parent directory is owned by the user
the dirname directory is owned by the user
the dirname directory is writable to the user
the user is root
rmdir will refuse to remove the root directory of a
Recursively remove the directory dirname and those of its
parent directories that become empty when a subdirectory is
removed. (For example, if a series of empty nested directories
exist, the -p option removes the deepest subdirectory and
all its parent directories until a non-empty directory is reached.)
A message is printed on the standard output if part of the path
remains for some reason.
Suppress any messages being printed when -p is in effect.
rmdir returns an exit code of 0 if all the specified
directories are removed successfully. Otherwise, it returns a
non-zero exit code.
To remove the directory tmpdir from the current directory:
To remove the subdirectory dir3 and its parent directories
dir2 and dir1 (where the parent directories
contain no other files):
$ cd ../../..
$ rmdir -p dir1/dir2/dir3
rmdir: dir1/dir2/dir3: Whole path removed.
rmdir is conformant with:
ISO/IEC DIS 99452:1992, Information technology Portable Operating System Interface (POSIX) Part 2: Shell and Utilities (IEEE Std 1003.21992);
AT&T SVID Issue 2;
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.
A version of rmdir
that can handle files greater than 2GB
is available in /u95/bin. See
for more information.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005