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

On ubuntu is there a way to create a directory path in one statement?

Lets say I have the dir /tmp/foo with no subdirectories, and I want to create /tmp/foo/bar/baz.

mkdir /tmp/foo/bar/baz fails with mkdir: cannot create directory /tmp/foo/bar/baz: No such file or directory

Is there a statement that can do this trick?

share|improve this question
up vote 2 down vote accepted
mkdir -p /tmp/foo/bar/baz

From 'man mkdir':

-p, --parents
      no error if existing, make parent directories as needed
share|improve this answer
Auww, your right. Overlooked that one. – RickyA Nov 1 '12 at 12:10

You must log in to answer this question.

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