mkdir's “-p” option

后端 未结 5 1830
南方客
南方客 2021-01-30 00:26

So this doesn\'t seem like a terribly complicated question I have, but it\'s one I can\'t find the answer to. I\'m confused about what the -p option does in Unix.

5条回答
  •  长情又很酷
    2021-01-30 01:02

    PATH: Answered long ago, however, it maybe more helpful to think of -p as "Path" (easier to remember), as in this causes mkdir to create every part of the path that isn't already there.

    mkdir -p /usr/bin/comm/diff/er/fence

    if /usr/bin/comm already exists, it acts like: mkdir /usr/bin/comm/diff mkdir /usr/bin/comm/diff/er mkdir /usr/bin/comm/diff/er/fence

    As you can see, it saves you a bit of typing, and thinking, since you don't have to figure out what's already there and what isn't.

提交回复
热议问题