rmdir

Official Description

Removes a directory.

Syntax

rmdir [-p] directory...
				

Options

-p removes all directories in a pathname.

Oddities

A directory must be empty before you can remove it, and you must have write permission in its parent directory.

Example

$ pwd
/home/obrien
$ mkdir sub1                 # Make a series of subdirectories
$ cd sub1
$ mkdir sub2
$ cd sub2
$ mkdir sub3
$ cd sub3
$ pwd
/home/obrien/sub1/sub2/sub3
$ cd
$
$ pwd
/home/obrien
$
$ rmdir -p sub1/sub2/sub3    # Remove them in one fell swoop
$
$ cd sub1                    # Gone
/bin/ksh: cd: sub1: [No such file or directory]
$
				

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.