Name

rmdir — stdin  stdout  - file  -- opt  --help  --version

Synopsis

rmdir [options] directories

The rmdir (remove directory) command deletes one or more empty directories you name:

rmdir /tmp/junk

Useful options

-p

If you supply a directory path (not just a simple directory name), delete not only the given directory, but the specified parent directories automatically, all of which must be empty. So the command:

rmdir -p one/two/three

will delete not only one/two/three, but also one/two and one.

To delete a nonempty directory and its contents, use (carefully) rm -r directory. Use rm -ri to delete interactively, or rm -rf to annihilate without any error messages or confirmation.

Get Macintosh Terminal Pocket Guide 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.