title: Extract .tar File to Current Directory Automatically with Shell Script
body: <p>I'm totally new to the world of bash, and I'm currently working on a script that will loop through a large directory and extract any .tar files it finds into it's current location.</p>
  
  <p>I'm using the following script:</p>
  
  <pre><code>for a in in /home/davidwright/attachments/*/*.tar
  do
    echo "extracting $x"
    tar -xvf $x
  done
  </code></pre>
  
  <p>Currently the file is extracting fine, but it is extracting to the location of my script. I need it to extract within the .tar's current directory. </p>
  
  <p>The solution is probably very simple, but I can't figure it out for the life of me.
  Thanks!</p>