DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Working with files and directories

Removing a directory

To remove an empty directory, use the rmdir(C) command, as follows:

rmdir directory

This will fail if there are any files or subdirectories in the directory. If this is so, you must either delete the files it contains, or move them to other directories. The only exceptions are the dot and dot-dot directories, which you cannot delete, and which are dealt with by the UNIX system itself.

You can remove a directory and any files it contains by using the rm -r option, as follows:

rm -r directory

Be very careful when doing this because the -r option tells rm to recursively enter any subdirectories and remove their contents. You may remove more than you expect. It is often safer to use the rm -i option. See ``Removing a file'' for information on interactive deletion. You must have write permission on a directory before you can remove it.


Next topic: Comparing directories
Previous topic: Copying a directory

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005