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?

1 Answer 1

mkdir -p /tmp/foo/bar/baz

From 'man mkdir':

-p, --parents
      no error if existing, make parent directories as needed
  • Auww, your right. Overlooked that one.
    – RickyA
    Nov 1, 2012 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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