linux - Command not found in Bash's IF-ELSE condition when using [! -d "$DIR"] -


i have code

#!/bin/bash  dir="test_dir/"; if [! -d "$dir"];     # if doesn't create     mkdir $dir fi 

but why executing gave me this:

./mycode.sh: line 16: [!: command not found 

what's right way it?

add space between [ , !. , before ] well.

#!/bin/bash  dir="test_dir/"; if [ ! -d "$dir" ];     # if doesn't create     mkdir $dir fi 

it's idea quote variable:

    mkdir "$dir" 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -