Under Unix-derived operating systems (Linux, Mac OS X, etc.), there are a pair of commands used to delete files and directories. rm
is used to "remove" file(s), rmdir
is used to "remove directory".
If you try to use rm
to delete a directory, you get this:
$ rm directory
rm: directory: is a directory
Why is this? Why is it necessary to use rmdir
to delete a directory, when rm
could do that?
The real irony is that rmdir
can only remove empty directories.
$ rmdir nonemptydirectory
rmdir: nonemptydirectory: Directory not empty
If you really mean to delete a directory and everything under it, you need to use this command:
$ rm -r directory
The "-r" tells the rm
command to operate recursively (meaning, delete this and everything under it). Sometimes a "-f" option is also included to force deletion of files that rm
would otherwise ask twice about.
All I'm saying is that rm
should be able to delete an empty directory if asked. If the given directory is not empty, it would complain (unless "-r" is specified).