[Bash] mkdir command

Zhentiw發表於2024-05-14

mkdir

To make a new directory, just execute the mkdir command with a list of new directory names to make as arguments:

mkdir hooray

and now a new directory called hooray exists.

You can create multiple directories at once:

mkdir one two

and now two new directories, one and two, exist.

mkdir -p

Suppose we want to make the following nested directory structure:

foo/
  bar/
    baz/
    qrs/

Instead of doing:

mkdir foo foo/bar foo/bar/baz foo/bar/qrs

We can just do:

mkdir -p foo/bar/baz foo/bar/qrs

and the necessary parent directories foo/ and foo/bar/ will be created automatically.

相關文章