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.

Is there an easy way to create all subdirectories of a path in linux ?

Something like

 mkdir   /a/b/c/d/e/f  

executed in / should create directories a,b,c,d,e,f

share|improve this question

migrated from stackoverflow.com Dec 10 '10 at 0:03

This question came from our site for professional and enthusiast programmers.

2 Answers 2

up vote 5 down vote accepted

Just use:

mkdir -p /a/b/c/d/e/f

The -p tells mkdir to create parent directories if they dont exist and doesn't give an error if the directory(ies) already exist(s). I wouldn't really consider this to be recursive.

share|improve this answer
    
No error is given if the directory already exists. If it already exists and is not a directory (regular file, pipe, special, etc.) then you get an error. –  robert Dec 9 '10 at 23:31

Use mkdir -p /a/b/c/d/e/f.

share|improve this answer

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.