graphics\overbutt.gifDeleting directories and files

You can delete directories and files using the Remove Directory (rmdir) and Remove File (rm) commands. Unless you specify a path name, bash looks in your working directory for the files to delete. Use a relative path name if the file exists in a subdirectory of your working directory. Use an absolute path name if the file is located above your working directory in the directory tree structure. For information about relative and absolute path names, see "Navigating the file system."

To delete directories or files you need write permission for the directory that contains the item. If you try to delete a file for which you do not have write permission, bash prompts you before deleting the file. You must move or delete the contents of a directory before you can remove it.

You can use command options when deleting files and directories. For example, you can tell bash to always prompt you before deleting a file (-i). You can set the Parent option (-p) when deleting directories to delete the parent directories that become empty as a result of removing the directory. For a more complete list of command options, see the Manual page for each commands.

To delete a directory

1. At the command line, type,

rmdir [options] <directory>...

2. Press ENTER.

graphics\nicon.gif graphics\nicon.gifNote

To delete a file

1. At the command line, type,

rm [options] <filename>...

2. Press ENTER.

graphics\nicon.gif Notes