title: Truncate a directory in bash
body: <p>Is there some elegant/simple way to delete the folder's contents in such a way there's no error output if it is empty?</p>
  
  <p>The following command</p>
  
  <pre><code>$ rm -r $dir/*   
  </code></pre>
  
  <p>doesn't work if the directory is empty, since in such a case, the wilcard <code>*</code> is not expanded and you get an error saying that <code>rm</code> cannot find file <code>*</code>.</p>
  
  <p>Of course, the standard way is check if it is empty (with <code>ls $dir | wc -w</code> or <code>find $dir -link 2</code> or any other related command), and deleting its contents otherwise.</p>
  
  <p>Is there an alternative way not to check folder contents and only "truncate" the directory instead?</p>