How to create nonexistent subdirectories recursively using Bash?
You can use the -p
parameter, which is documented as:
-p, --parents
no error if existing, make parent directories as needed
So:
mkdir -p "$BACKUP_DIR/$client/$year/$month/$day"
While existing answers definitely solve the purpose, if your'e looking to replicate nested directory structure under two different subdirectories, then you can do this
mkdir -p {main,test}/{resources,scala/com/company}
It will create following directory structure under the directory from where it is invoked
├── main│ ├── resources│ └── scala│ └── com│ └── company└── test ├── resources └── scala └── com └── company
The example was taken from this link for creating SBT directory structure