Reputation: 1009
I understand the use of mkdir -p
for cases like: mkdir -p foo/bar
where neither of those directories yet exists, which I was surprised to see someone using mkdir -p bar
. Does it ever make sense to use -p when there is no /
in the following argument, i.e. there is only one path segment?
My understanding is that mkdir -p foo
is equivalent to mkdir foo
in all cases. Is there a case I'm missing?
Upvotes: 0
Views: 26
Reputation: 125788
mkdir foo
will report an error if a directory named "foo" already exists; mkdir -p foo
will not. Essentially, in this case the -p
just tells mkdir
that it's ok if the directory already exists.
Upvotes: 1