This seems like such a Day 0 problem. I need to create a 2-level folder structure.

I tried:

sudo mkdir parent/child >>> mkdir: cannot create directory ‘parent/child’: No such file or directory 
sudo mkdir -p parent/child >>> mkdir: cannot create directory ‘parent’: Permission denied 
4

1 Answer

Most file systems do not work in a fashion similar to S3 block storage, making the automatic generation of what appears to be a fully-qualified path an automagical process. Generally, to do what you are attempting to do, a person would perform these actions:

mkdir parent mkdir parent/child 

However, if you insist on doing this as a one-liner, you can try this:

mkdir -p ~/{parent/{child}} 

What’s nice about this is that you can create multiple directories pretty much simultaneously:

mkdir -p ~/{parent/{child1,child2,child3},uncle,aunt,Morty} 

This will give you lots of directories all at once, so long as you remember -p and the curly brackets 👍🏻

1

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