Create new directories and subdirectories in Unix using a single terminal command

It’s funny how programmers get in a "rut", using the same old coding habits and command line syntax for years on end.  I just found that you can create new directories and subdirectories with a single Unix mkdir command using the -p parm.

mkdir -p top_level_directory/child_directory/another_child_directory

And if you’re curious, this won’t work (I tried it):

mkdir -p onemoredir/../anotherdir

Goes to show you that we should follow the same advice we give the junior developers – "check the man page".

You may also like...

%d bloggers like this: