We all know that on the terminal command-line you use mkdir to make directories. (Honestly, if ya didnโt, ya should. ๐)
I only recently found out about the -p โflagโ/modifier for mkdir with which we can make multiple *sub*-directories at once:
mkdir -p top/middle/bottom
Now I have a folder called โtopโ which has a folder โmiddleโ inside. โmiddleโ, has its own folder inside called โbottomโ1.
BUT WAIT THEREโS MORE!โฆ
With -p flag you can also make multiple directories at the *same sub-level*. Use a pair of { } and separate the names by ,. This time, say, Iโd get โmiddleโ to contain 3 directories inside instead of one -
mkdir -p top/middle/{bottom1,bottom2,bottom3}
ABSURD EXAMPLE:
I already knew that you can add โ โ between names to make multiple directories at once at the same level: mkdir dir1 dir2 dir3, but by
combining all of this into an abusurd example I would never actually use, I can make a giant (completely made up nonesense) tree structure at once:
mkdir -p newProject/client/{assets/{pdfs,images},dynamic/{configs,media}} otherProject/server/{db{query,cache},app/{model,view}}
Which will make this:
/
โโ newProject/
โ โโโ client/
โ โโโ assets/
โ โ โโโ images/
โ โ โโโ pdfs/
โ โโโ dynamic/
โ โโโ configs/
โ โโโ media/
โโ otherProject/
โโ server/
โโโ app/
โ โโโ model/
โ โโโ view/
โโโ dbcache/
โโโ dbquery/
So, a random possibly useful thing to knowโฆ
Cheers!
โฏ โ โ โฆ โฎ โฏ โ โฆฟ โฏ โ โ โฆ โฎ โฏ โ โฆฟ โฏ โ โ โฆ โฎ โฏ โ โฆฟ โฏ โ โ โฆ
-
Otherwise, weโd do it in steps (
mkdir top, thencd top, thenmkdir middle, thencd middle, thenmkdir bottom).ย ↩