Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
1  
man mkdir, will give you the information. –  Johan Jul 19 '10 at 5:24
1  
man pages suck. –  Daniel Smith Mar 19 '13 at 1:10
    
man, pages suck. –  Salem Jul 19 '13 at 18:28
    
man pages suck. someone can give an answer in 10 seconds compared to someone reading the man pages for 30+ minutes to find an answer. –  duckx Dec 16 '13 at 4:42
add comment

1 Answer

up vote 12 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.

share|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  
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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