title: Finding files from list and copying them into new directory
body: <p>I want to find files via the command line terminal for OS X and then copy the files that were found to a new directory. The filenames of the files I want to find are in a listexample.txt file and there are about 5000 file names in there.</p>
  
  <p>The file listexample.txt looks like this:</p>
  
  <pre><code>1111 00001 55553.bmp
  1113 11312 24125.bmp
  …
  </code></pre>
  
  <p>I tried around with thing like this:</p>
  
  <pre><code>find /directory -type f "`cat listexample.txt`" -exec cp {} …
  </code></pre>
  
  <p>but can't get it to run.</p>
  
  <p>I have now this, but it doesn't work:</p>
  
  <pre><code>cat listexample.txt | while read line; do grep "$line" listexample.txt -exec find /directorya "$line" -exec cp {} /directoryb \; done
  </code></pre>
  
  <p>The idea is to read the lines of list example.txt, then take the line with grep, find the file in directory a and then copy the found file over to a new directory b. I think because of the nature of my file names, see above, there is a problem with spaces in the name as well.</p>
  
  <p>I also started this approach to see what is going on, but didn't get far.</p>
  
  <pre><code>for line in `cat listexample.txt`; do grep $line -exec echo "Processing $line"; done
  </code></pre>