Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

up vote 6 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
1  
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .