title: how to tar without the parent directory but with the last directory
body: <p>I am trying to tar a directory without the parent directories and I have found a solution so far which removes the parent directories and tar all the files under a directory called (DIR) to a DIR.tar.gz file using the following:</p>
  
  <pre><code>tar -cvzf $DIR.tar.gz -C $path/$DIR .
  </code></pre>
  
  <p>But if I want to untar the tared file, it will untar all the files in the current directory, however, I want to be able to tar the dir in a way which when I use tar -xzvf, it will untar it into folder called DIR. IT should be simple, but I am not able to find the solution on the net. Any hint?</p>