title: How to create directory if doesn't exists in sftp
body: <p>I want to create a directory if it doesn't exists after login to sftp server.</p>
  
  <p>test.sh</p>
  
  <pre><code>sftp name@example.com &lt;&lt; EOF
  mkdir test
  put test.xml
  bye
  EOF
  </code></pre>
  
  <p>Now i call test.sh and upload different files each time to test folder. When running this</p>
  
  <pre><code>mkdir test
  </code></pre>
  
  <p>First time it works and second time it throws Couldn't create directory: Failure error?</p>
  
  <p>How to create a directory if doesn't exists and if exists don't create directory in sftp.</p>