title: Moving a directory atomically
body: <p>I have two directories in the same parent directory.  Call the parent directory <strong>base</strong> and the children directories <strong>alpha</strong> and <strong>bravo</strong>.  I want to replace <strong>alpha</strong> with <strong>bravo</strong>.  The simplest method is:</p>
  
  <pre><code>rm -rf alpha
  mv bravo alpha
  </code></pre>
  
  <p>The mv command is atomic, but the rm -rf is not.  Is there a simple way in bash to atomically replace <strong>alpha</strong> with <strong>bravo</strong>?  If not, is there a complicated way?</p>
  
  <p>ADDENDUM:</p>
  
  <p>By the by, it's not an insurmountable problem if the directory doesn't exist for a short period. There's only one place that tries to access alpha, and it checks if alpha exists before doing anything critical. If not, it gives an error message. But it would be nice if there was a way to do this. :) Maybe there's some way to modify the inodes directly, or something...</p>