Shell script to test whether a directory exists and if not create it?

Posted by George Edison on Stack Overflow See other posts from Stack Overflow or by George Edison
Published on 2010-05-30T04:45:16Z Indexed on 2010/05/30 4:52 UTC
Read the original article Hit count: 201

Filed under:
|
|

I am trying to create a script to detect whether a directory exists, and if it does, to create it.

How can I do that?

I did some digging and found a clue:

test -d directory

...will return true or false depending on whether the directory exists or not.

But how do I tie this together with mkdir?

© Stack Overflow or respective owner

Related posts about shell

Related posts about directory