How to create multiple directories?

You can create multiple directories at once using the mkdir command by listing the directory names separated by spaces. Here’s how to do it:

Basic Syntax:

mkdir directory1 directory2 directory3

Example:

To create three directories named dir1, dir2, and dir3, you would use:

mkdir dir1 dir2 dir3

Creating Nested Directories:

If you want to create nested directories (e.g., parent/child), you can use the -p option:

mkdir -p parent/child

This command will create the parent directory and the child directory inside it, even if the parent directory does not already exist.

Using Brace Expansion:

You can also use brace expansion to create multiple directories with similar names:

mkdir dir{1,2,3}

This command creates dir1, dir2, and dir3.

If you have any further questions or need more examples, feel free to ask!

0 Comments

no data
Be the first to share your comment!