unix - what the difference betwen mkdir vs mkdir -p -


i tried create folder in local git repo using mkdir. didn't work, mkdir -p works.

why?

i'm using mac os way. checked definition of mkdir -p. still don't quite understand.

say you're in directory:

/home/users/john 

and want make 3 new sub directories end with:

/home/users/john/long/dir/path 

while staying in "/home/users/john", fail:

mkdir long/dir/path 

you have make 3 separate calls:

mkdir long mkdir long/dir mkdir long/dir/path 

the reason mkdir default creates directories 1 level down. adding "-p" flag, mkdir make entire set in 1 pass. is, while won't work:

mkdir long/dir/path 

this work:

mkdir -p long/dir/path 

and create 3 directories.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -