DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

rmdir(C)


rmdir -- remove directories

Syntax

rmdir [ -p ] [ -s ] dirname ...

Description

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:

-p
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.

-s
Suppress any messages being printed when -p is in effect.
rmdir will refuse to remove the root directory of a mounted filesystem.

Exit values

rmdir returns an exit code of 0 if all the specified directories are removed successfully. Otherwise, it returns a non-zero exit code.

Examples

To remove the directory tmpdir from the current directory:

rmdir tmpdir

To remove the subdirectory dir3 and its parent directories dir2 and dir1 (where the parent directories contain no other files):

$ pwd
/u/homedir/dir1/dir2/dir3
$ cd ../../..
$ rmdir -p dir1/dir2/dir3
rmdir: dir1/dir2/dir3: Whole path removed.

See also

rm(C)

Standards conformance

rmdir is conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
AT&T SVID Issue 2;
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003