2

How to create a complete directory structure with a single command?

By this question I mean, if I wanted to create a directory structure like below in one go using a command.

/abcd/efgh/ijkl/mnop/qrst/uvwx/yz/

then what command shall I use?

Zanna
  • 70,465
Hrish
  • 2,343

2 Answers2

5

mkdir -p /abcd/efgh/ijkl/mnop/qrst/uvwx/yz/

mkdir is "make directory"

The -p option creates the parent directories if they do not already exist.

Carl H
  • 6,181
  • 6
  • 27
  • 41
1

Here is the answer to the question,below command will do the job you want in just the way you want :) This can be done with mkdir (make directory command) as shown below:

root@test:~# sudo mkdir -p /abcd/efgh/ijkl/mnop/qrst/uvwx/yz/  
root@test:~#   

If you want it to show you the directories it created while it is working then use verbose with it as shown below:

root@test:~# sudo mkdir -pv /abcd/efgh/ijkl/mnop/qrst/uvwx/yz/  
mkdir: created directory `/abcd'
mkdir: created directory `/abcd/efgh'  
mkdir: created directory `/abcd/efgh/ijkl'  
mkdir: created directory `/abcd/efgh/ijkl/mnop'  
mkdir: created directory `/abcd/efgh/ijkl/mnop/qrst'  
mkdir: created directory `/abcd/efgh/ijkl/mnop/qrst/uvwx'  
mkdir: created directory `/abcd/efgh/ijkl/mnop/qrst/uvwx/yz/'  
root@test:~#  

Enjoy!! :)

Hrish
  • 2,343
  • 2
    Please do not post a (duplicate) answer, while you are aware of the duplicate. Either post an answer there or edit the question / title to improve the findability. – Jacob Vlijm Feb 17 '15 at 10:30