Bash mkdir and subfolders

Uffo picture Uffo · Feb 11, 2012 · Viewed 109.5k times · Source

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?

Answer

FatalError picture FatalError · Feb 11, 2012

You can:

mkdir -p folder/subfolder

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