title: Check if directory does not exist
body: <p>I have written a script to check in var/log directory, and it takes all the directories in there and checks if there is an archive directory in those directories. If an archive directory not exist, I want to create it, but once it's created the script tries to create it again.</p>
  
  <pre class="lang-bash prettyprint-override"><code>vdir=$(sudo sh -c "find /var/log/ -maxdepth 1 -type d ! -name "archive"" )
  for i in $vdir ;do
      echo $i
      if [[ ! -d $i/$arc ]];then
          sudo sh -c "mkdir $i/$arc"
          echo "$date:$HN:Creating:$i/$arc:directory" &gt;&gt; logrotation.log
      fi
  done
  </code></pre>
  
  <p>When I execute above code it gives me this error. Seems the script is not checking the condition.</p>
  
  <pre><code>mkdir: cannot create directory ‘/var/log/speech-dispatcher/archive’: File exists
  </code></pre>