mkdir -p

There are two main uses of mkdir -p:

1. No error is reported when there is a directory with the same name (used when no error is thrown)

2. Create a directory recursively

 

 

1. No error is reported when verifying that a directory with the same name exists

-- In the current directory, create two folders a and b at the same time

mkdir  a  b

 

If a folder with the same name does not exist in the current directory, it will be created successfully.

.
├── a
└── b

Execute the mkdir a b command again (the a and b folders already exist in the current path), and an error will be reported:

mkdir: cannot create directory ‘a’: File exists
mkdir: cannot create directory ‘b’: File exists

 

No error will be reported if mkdir -pab is executed.

 

 

2. Verify that the directory is created recursively

mkdir -p  a/b/c

Folder a will be created under the current path, folder b will be created under folder a, and folder c will be created under folder b

.
├── a
├── b
└── c
    └── d
        └── e

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326934534&siteId=291194637