To prevent accidents, rmdir will refuse to remove directories that contains files and/or other directories. Which is why you received the error message:
rmdir: a: Directory not empty
This will also prevent you removing a parent directory, since by its very name, it has to contain your current working directory. Logic also dictates that you can't remove your current directory since this would involve you being lost in limbo'!
- 4 -
The rmdir has a handly little option, called -p. It's purpose is to ask the shell to not only remove a directory, but also all of its parent directories - so long as each parent is empty. Don't worry about accidentally deleting something you shouldn't have, the design of the Unix filesystem and its simple rules I mentioned above, prevent disaster from occuring. The creators of Unix were nothing if not geniuses.
Enter:
rmdir -p a/sub
...oh dear, still an annoying error message:
rmdir: a/sub: Directory not empty
- 5 -
Now press the up cursor key to bring back up the last command, but this time add /subsub before pressing the Return key, like so:
rmdir -p a/sub/subsub
Bingo, all three directories have been removed!
|