title: Bash script: remove extension from file name
body: <p>I have the following bash script:</p>
  
  <pre><code>tar -zxvf $1
  cd $1
  </code></pre>
  
  <p>It should extract the archive file and enter the directory that was created. Typically, package archive file creates directory with the same name, as the file, without extension, for example, mpc-1.0.1.tar.gz creates mpc-1.0.1 directory. How can I change the line <code>cd $1</code> to get directory name? Archive files have several extensions: tar.gz, tat.xz, tar.bz2. </p>