title: Copy and create a directory with date timestamp where it does not exist
body: <p><strong>Background:</strong></p>
  
  <p>I have a Jenkins task that is executing and before running i want to take a copy of a folder and move it to another directory which does not exist and is a dynamic timestamp. </p>
  
  <p>For the purposes of this argument i am not able to create variables to store anything, it must be accomplished without them. I have seen this other question on stackoverflow <a href="https://stackoverflow.com/questions/1529946/linux-copy-and-create-destination-dir-if-it-does-not-exist">here</a>, and this seems to confirm the approach i am going for.</p>
  
  <p><strong>Question:</strong></p>
  
  <p>What is the best way to achieve this for Linux/Unix? </p>
  
  <p>I have an idea below but i want to check if this is the best approach or not. It starts by making the directory <code>mkdir -p</code> with the location of the directory <code>/tmp/backup/myapp/</code> and the date timestamp as the final folder name <code>$(date +%Y%m%d%H%M%S)</code>, it then calls a recursive copy <code>cp -r</code> and provides the source directory to be copied <code>/var/www/html/myapp</code> and then passes in the original location url as the destination <code>$_</code></p>
  
  <p><strong>Suggested Answer</strong></p>
  
  <pre><code>mkdir -p /tmp/backup/myapp/$(date +%Y%m%d%H%M%S) &amp;&amp; cp -r /var/www/html/myapp $_
  </code></pre>