[Previous] [Contents] [Index] [Next]

rmdir

Remove directories (POSIX)

Syntax:

rmdir [-p] dir...

Options:

-p
Remove the entire directory path (consisting only of directories that are empty except for the named pathname components) of the directories specified on the command line. (See example.)
dir
The pathname of an empty directory to be removed.

Description:

The rmdir utility removes the directory specified by each dir operand, provided the directory is empty.

The rmdir utility processes directories in the order they're specified on the command line. If you specify a parent directory, you should specify its subdirectory before the parent directory. That way, the parent directory will be empty when the rmdir utility tries to remove it.

Examples:

Remove the subdirectory oldfiles from the /home/fred directory:

rmdir /home/fred/oldfiles

Remove the directory path dir1/dir2/dir3:

rmdir -p dir1/dir2/dir3

For this command, rmdir first removes dir1/dir2/dir3. If this is successful, it then removes dir1/dir2. If this is also successful, it removes dir1.

Exit status:

0
Each directory specified by a dir operand referred to an empty directory and was removed successfully.
>0
An error occurred.

See also:

rm, find


[Previous] [Contents] [Index] [Next]