What does the mkdir -p flag do? i.e the '-p' part?
-p Will create nested directories, but only if they don't exist already.
For example: suppose you have a directory /foo already that you have write permissions for.
It is also an idempotent operation, because if you run the same command over again, you will not get an error, but nothing will be created.