title: How to Properly Use xargs With cp
body: <p>What I want to do is read a list of filenames from an index file and then copy each listed file to another directory, but I'm having a little trouble properly stringing xargs and cp together.</p>
  <pre><code>head -n 150 ../indexes/index.txt | xargs cp ~/path/to/destination/
  </code></pre>
  <p>This gives the following error:</p>
  <pre><code>cp: target 'foo.txt': Not a directory
  </code></pre>
  <p>where <code>foo.txt</code> is the 150th filename listed in index.txt. Clearly cp should be taking the input from xargs as its first operand and not the second, but how do I get it to do this?</p>