Using rm -rf with a directory
<p>I tried to search on SO, but not able to find the difference between the following commands.   if I have a directory named dir,  how the below commands differ?</p>

<ul>
<li><code>rm -rf dir/*</code></li>
<li><code>rm -rf dir/</code></li>
<li><code>rm -rf dir</code></li>
</ul>

<p>Also how do the user permissions on the directory affect the outcome, if the id running the command is not the owner or not even in the group of the owner?</p>

<p>I am adding the command to do rm -rf in a shell script I am working on and need help in understanding the difference between the above commands.</p>