Create multiple directories at once in terminal
Here are different strategies for creating multiple directories/folders or subdirectories at once in a linux terminal.
Using mkdir
positional arguments
mkdir
can be supplied multiple positional arguments.
1mkdir dir1 dir2
Using bash
brace expansion + mkdir
mkdir
can be supplied multiple positional arguments using bash
’s brace expansion.
Creating directories
1mkdir {dir1,dir2}
Creating subdirectories
-p
flag is used to create the parent directory if it does not already exist.
1mkdir -p dir/{dir1,dir2}
Creating directories with bash
sequences
1mkdir dir{1..5}