#!/bin/sh
(
IFS=/
mkdir -p "$*"
)
The expansion of "$*"
will be a single quoted string consisting of all arguments to the script concatenated together with the first character of $IFS
as a delimiter. This is why we also set $IFS
to /
.
I'm running that in a subshell to avoid setting IFS
for the rest of the script (it changes the behavior of certain things, like how read
works). If there's nothing else in the script, you can leave (
and )
out.
Testing:
$ tree
.
`-- script.sh
0 directory, 1 file
$ ./script.sh 1 2 3 4 {a..k}
$ tree
.
|-- 1
| `-- 2
| `-- 3
| `-- 4
| `-- a
| `-- b
| `-- c
| `-- d
| `-- e
| `-- f
| `-- g
| `-- h
| `-- i
| `-- j
| `-- k
`-- script.sh
15 directories, 1 file