title: Bash: Loop over files listed in a text file and move them
body: <p>I have a directory (directory A) with 10,000 files in it. I want to move some of them to directory B and the others to directory C.  I made a text file that contains the names of all the files I want to move to directory B and another one with the names of all the files that I want to move to directory C.  How can I write a bash for loop to move these files to the new directories.  </p>
  
  <p>Pseudocode:</p>
  
  <p>for file in textfileB:<br>
     move file from directory A to directory B</p>
  
  <p>for file in textfileC:<br>
     move file from directory A to directory C</p>
  
  <p>Sorry if this is asked somewhere else, but I've spent hours trying to learn bash and I just don't get it.  I wasn't able to find something similar enough in another thread that I could understand (maybe I just don't know the right search words).</p>
  
  <p>I got something like this, but I couldn't get it working:  </p>
  
  <pre><code>FILES=[dont' know what goes here? An array? A list?  
  </code></pre>
  
  <p>Can I just state the text file name and if so what format do the files have to be?  name1.ext, name2.ext, or name1.ext  name2.ext]</p>
  
  <pre><code>for f in $FILES; do mv $f /B/$f [not sure about the second argument for mv]; done
  </code></pre>
  
  <p>thx</p>
  
  <p>BTW
  Mac OSX 10.6.8 (Snow Leopard)
  Apple Terminal v. 2.1.2 / 273.1
  Bash 3.2</p>