title: How can I create directories during a copy in bash/zsh/ksh?
body: <p>I get the following messages often, for instance when coping dev files to a master branch</p>
  
  <pre><code>cp: /Users/Masi/gitHub/shells/zsh/dvorak: No such file or directory
  cp: /Users/Masi/gitHub/shells/zsh/dvorak2: No such file or directory
  </code></pre>
  
  <p>I would like to be asked about the creation of the given folders such that my initial command will be run if I answer yes to the question(s).</p>
  
  <p><strong>My attempt in pseudo-code when I am trying to copy a file to a directory which does not exists</strong></p>
  
  <pre><code>if no such a directory exists, then asks users about to create it:
     if yes, then mkdir directory AND run the initial command again
     else do noting
  </code></pre>
  
  <p><strong>Problems</strong></p>
  
  <ol>
  <li><strong>To change the warning message:</strong> Which file does control the "No such file or directory" -command?</li>
  <li><strong>To scrape the Path in the initial command AND mkidr Path without the file</strong>: How would scrape the Path in the initial command?</li>
  <li><strong>To scrape from the end with your chosen language such as AWK:</strong> How would you remove the last match in the Path when / is the field separator? <em>I am not sure how you can scrape letters starting from the end with AWK.</em> </li>
  </ol>