title: How to extract a single file from tar to a different directory?
body: <p>I know that I can use following command to extract a single file to the current working directory (assume I have a tar file named test.tar and a file named testfile1 and testfile2 are inside it):</p>
  
  <pre><code>$tar xvf test.tar testfile1
  </code></pre>
  
  <p>And I can use -C option to extract files to another directory:</p>
  
  <pre><code>$tar xvf test.tar -C anotherDirectory/
  </code></pre>
  
  <p>When I incorporate the above two techniques together, I suppose that I can extract a single file to another directory. </p>
  
  <pre><code>$ tar xvf test.tar testfile1 -C anotherDirectory/
  </code></pre>
  
  <p>But the result is I can only extract the testfile1 to the current working directory, rather than the anotherDirectory.</p>
  
  <p>I want to know how can I extract a single file from tar to a different directory?</p>