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

link|improve this question
feedback

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

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

2 Answers

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

link|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
feedback

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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