Make and Delete Directories

As a programmer, you need to be quick from the command prompt. One of the most common tasks is make and delete directories. In Unix and Linux flavored operating systems, including OS X, you can create new directories with the mkdir command.

mkdir juixe

To create nested directories you can use the -p option.

mkdir -p juixe/src/java

You can also create more than one directory at a given time by using brackets.

mkdir {lib,src,doc}

The above command will create three directories, lib, src, and doc. The kewl thing about mkdir is that you can mix both nested directories structure with with brackets to create a complete directory structure.

mkdir -p juixe/{lib,src,doc/html,doc/pdf}

To delete a directory you can use the rmdir command, but I hardly ever use that command because the directory needs to be empty and does not delete directories recursively. To remove directories recursively you can use the rm command with the -r option.

rm -r juixe

Technorati Tags: , , , , ,