How can I create multiple nested directories in one command?
mkdir -p /just/one/dir
But I need to create multiple different nested directories...
How can I create multiple nested directories in one command?
mkdir -p /just/one/dir
But I need to create multiple different nested directories...
To add to the above answers you can also do (in csh
, tcsh
, ksh
, bash
, zsh
, fish
, yash -o brace-expand
):
mkdir -p /path/{to,a}/{lot,of}/directories
bash
and similar shells supporting that particular feature (brace expansion) that is. For more information, see http://wiki.bash-hackers.org/syntax/expansion/brace
– phk
Jan 17 '17 at 17:25
csh
and similar shells supporting that particular feature (that comes from csh
(late 70s)).
– Stéphane Chazelas
Jan 17 '17 at 17:29
bash
,")
– phk
Jan 17 '17 at 17:32
rc
/es
don't support it either but have a similar feature with mkdir /path/^(to some)^/directories
– Stéphane Chazelas
Jan 17 '17 at 17:38
Reading the man page is always a good place to start.
The -p
flag will create the required intermediate directories on the path.
--
mean? – user3142695 Jan 17 '17 at 22:28-s
/--some-thing
) and only (positional) arguments from now on. See also http://unix.stackexchange.com/q/11376/117599 It's not strictly necessary here, I just added it to signify further that those are multiple positional arguments. – phk Jan 17 '17 at 22:29