title: Replacing strings using sed and a file as input
body: <p>I have a bunch of files, in a lot of different folders that I need to edit. 
  Each folder has a subfolder that has another subfolder nested in it. 
  I have the folder names (genome_list.txt) and each the files that need to be edited have the same name in all the folders. 
  I want to use a list of strings from one file, to delete such strings from another file. 
  Here is what my failed attempt to do so looks like</p>
  
  <pre><code>for dir in $(cat genome_list.txt)
  do 
  cd ${dir}/ref_map_${dir}
  for samplename in $(cat remove_from_samples.txt )
  do 
  sed -i 's/${samplename}//g' ../samples.txt
  done
  cd ../..
  done
  </code></pre>
  
  <p>Files look like this:</p>
  
  <pre><code> cat remove_from_samples.txt
   -s CHJ111.fq
   -s CHJ727.fq
  
   cat samples.txt
   -s CHJ062.fq -s CHJ111.fq -s CHJ522.fq -s CHJ_528.fq -s CHJ727.fq
  
   #Desired output:
   -s CHJ062.fq -s CHJ522.fq -s CHJ_528.fq
  </code></pre>