Please enable JavaScript eh!

 ⌘ Web Mechanic ⌘ 

Bash Scripting


rmdir

remove directory

As with ALL Terminal commands, this requires your FULL attention.
Files deleted this way are NOT in your Trash so CANNOT be 'Put Back'

We created some directories on your Desktop in the previous page. It would be good to know how to delete them, right?

If you are already in your Desktop directory, deleting a directory is straight-forward:

rmdir [directory]

As per the last page, you should have 4 new directories on your Desktop named '1' '2' '3' and '4'. If not, review that page and create them again.

1, 2, and 3 should be empty. 4 contains 2 subdirectories.

For now we want to delete 1, 2, and 3 ...

rmdir 1 2 3

That was too easy! Even if you named them 'First', 'Second', and 'Third', this syntax will still work.

Remember if a name has spaces in it, you must quote the whole name:

mkdir First Third "The Second"
rmdir First Third "The Second"

If you remember this page, we talked about using the keyboard arrow keys to see previous commands entered. This is a good example to try a few times.

rmdir only works if there are no files in the directory

Well, that could be a problem. Directories usually contain files - that's what they're for, right? So how do we handle this problem?

rm