mkdir -p: Nested Directories
Creating a/b/c without -p requires three separate mkdir commands:
mkdir a
mkdir a/b
mkdir a/b/c
The -p flag (parents) handles the whole thing in one shot.
Usage
mkdir -p data/raw/csv
This creates:
data/(if it doesn't exist)data/raw/(if it doesn't exist)data/raw/csv/(if it doesn't exist)
If any of those directories already exist, -p skips them silently instead of throwing an error.
Verify the result
ls data
# raw
ls data/raw
# csv
Real-world patterns
Setting up a data project directory structure in one command:
mkdir -p project/{data/{raw,processed},notebooks,reports}
This creates:
project/
├── data/
│ ├── raw/
│ └── processed/
├── notebooks/
└── reports/
Brace expansion
The {raw,processed} syntax is called brace expansion. It creates multiple directories at once. Your playground supports it — try it.
Practice
Create the nested path data/raw/csv in one command using mkdir -p.