What does the mkdir -p flag do? i.e the '-p' part?

link|improve this question

48% accept rate
1  
man mkdir, will give you the information. – Johan Jul 19 '10 at 5:24
feedback

1 Answer

up vote 3 down vote accepted

-p Will create nested directories, but only if they don't exist already.

For example: suppose you have a directory /foo already that you have write permissions for.

mkdir -p /foo/bar/baz  # creates bar and baz within bar under existing /foo

It is also an idempotent operation, because if you run the same command over again, you will not get an error, but nothing will be created.

link|improve this answer
great, I couldn't find the flag in the man page when searching in Goog, strange! – user27449 Jul 19 '10 at 4:35
1  
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.