What does the -p flag do in "mkdir -p"?

What does the -p flag do in mkdir -p?

0

1 Answer

The -p flag will create nested directories, but only if they don't exist already.

For example, suppose you have a directory /foo that you have write permissions for.

mkdir -p /foo/bar/baz # creates bar and baz within bar under existing /foo

It is also an idempotent operation, because if you run the same command over again, you will not get an error, but nothing will be created.

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like