Bash mkdir and subfolders [duplicate]

Why I can't do something like this? mkdir folder/subfolder/ in order to achive this I have to do:

mkdir folder
cd folder
mkdir subfolder

Is there a better way to do it?


You can:

mkdir -p folder/subfolder

The -p flag causes any parent directories to be created if necessary.


To create multiple sub-folders

mkdir -p parentfolder/{subfolder1,subfolder2,subfolder3}

FWIW,

Poor mans security folder (to protect a public shared folder from little prying eyes ;) )

mkdir -p {0..9}/{0..9}/{0..9}/{0..9}

Now you can put your files in a pin numbered folder. Not exactly waterproof, but it's a barrier for the youngest.