mkdir's “-p” option

后端 未结 5 2006
南方客
南方客 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:13

    mkdir [-switch] foldername

    -p is a switch which is optional, it will create subfolder and parent folder as well even parent folder doesn't exist.

    From the man page:

    -p, --parents no error if existing, make parent directories as needed
    

    Example:

    mkdir -p storage/framework/{sessions,views,cache}
    

    This will create subfolder sessions,views,cache inside framework folder irrespective of 'framework' was available earlier or not.

提交回复
热议问题