How to use Bash to create a folder if it doesn't already exist?

前端 未结 6 1314
暖寄归人
暖寄归人 2020-12-02 06:43
#!/bin/bash
if [!-d /home/mlzboy/b2c2/shared/db]; then
    mkdir -p /home/mlzboy/b2c2/shared/db;
fi;

This doesn\'t seem to work. Can anyone help?<

6条回答
  •  醉梦人生
    2020-12-02 07:00

    There is actually no need to check whether it exists or not. Since you already wants to create it if it exists , just mkdir will do

    mkdir -p /home/mlzboy/b2c2/shared/db
    

提交回复
热议问题