23.17 Problems Deleting Directories
% The rmdir command often confuses new users. It will only remove a directory if it is completely empty; otherwise, you'll get an error message: % As in the example, ls will often show that the directory is empty. What's going on? It's common for editors and other programs to create "invisible" files (files with names beginning with a dot). The ls command normally doesn't list them; if you want to see them, you have to use ls -a (16.11 ) : % Here, we see that the directory wasn't empty after all: there's a
backup file that was left behind by some editor. You may have used
% Other pitfalls might be files whose names consist of "non-printing" characters or blank spaces - sometimes these get created by accident or by malice (yes, some people think this is funny). Such files will usually give you "suspicious" ls output (16.13 ) (like a blank line). If you don't want to worry about all these special cases, just use rm -r : % This command removes the directory and everything that's in it, including other directories. A lot of people warn you about it; it's dangerous because it's easy to delete more than you realize. Personally, I use it all the time, and I've never made a mistake. I never bother with rmdir . - |
|