Make directory trees on unix and linux with mkdir command options

Some times while working on live servers of unix or linux, on shell command line, we required to create different directories tree, so we are using mkdir command.

For creating many sub directories at a time we can use one of the switch of mkdir command.

which is -p, while using -p with mkdir it will create as many sub directories as you wish.

below is the very good example of it, to defining the directory trees with the mkdir command, only with one command from bash shell prompt.

mkdir -p /testdir/abc/def/ghi/jkl/mno/p/q/r/s/t/u

Now you can check it, by doing more cds into each dir.

Hope this will save your lots of time. So in such a way we can create complex directory structure with mkdir command and can save our lots of time. [ Time is money. Invest it by saving it.]

Back to top