Wednesday, 2 April 2008

Creating multiple subdirectories at once

If you want to create a directory with many parent directories that don’t already exist it can be a pain to create each directory one at a time. mkdir provides the flag -p to create all the directories if they don’t already exist to speed this process up and make it less tedious.

To make its use clear here is an example:
user@computer:~> mkdir -pv /tmp/test/directory/subdirectory1/subdirectory2
mkdir: created directory `/tmp/test’
mkdir: created directory `/tmp/test/directory’
mkdir: created directory `/tmp/test/directory/subdirectory1′
mkdir: created directory `/tmp/test/directory/subdirectory1/subdirectory2

No comments:

Post a Comment