[Bash] mkdir command

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.

posted @ 2024-05-14 03:07  Zhentiw  阅读(5)  评论(0编辑  收藏  举报