How can you create multiple directories at once in Linux?

0110

You can create multiple directories at once in Linux using the mkdir command. Here are a couple of methods:

Method 1: List Directory Names

You can specify multiple directory names separated by spaces:

mkdir directory1 directory2 directory3

Method 2: Using Brace Expansion

You can use brace expansion to create a series of directories:

mkdir project/{src,bin,docs}

This command creates three directories: src, bin, and docs inside the project directory.

Method 3: Creating Parent Directories

If you need to create parent directories as well, use the -p option:

mkdir -p parent/child1/child2

This command creates parent, child1, and child2 directories in one go.

Summary

  • Use mkdir with multiple names or brace expansion.
  • Use -p to create parent directories as needed.

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

0 Comments

no data
Be the first to share your comment!