title: cat lines from X to Y of multiple files into one file
body: <p>I have many huge files in say 3 different folders from which i would like to copy say lines from X to Y of files of the same name and append them into a new file of the same name. 
  I tried doing </p>
  
  <pre><code>ls seed1/* | while read FILE; do
  head -n $Y  | tail -n $X seed1/$FILE seed2/$FILE seed3/$FILE  &gt; combined/$FILE
  done
  </code></pre>
  
  <p>This does the job for the first value of $FILE, but this does not return the prompt, and hence I am unable to execute this loop.</p>
  
  <p>For example i have the following files in three different folders, seed1, seed2 and seed3:</p>
  
  <pre><code>seed1/foo.dat
  seed1/bar.dat
  seed1/qax.dat
  
  seed2/foo.dat
  seed2/bar.dat
  seed2/qax.dat
  
  seed3/foo.dat
  seed3/bar.dat
  seed3/qax.dat
  </code></pre>
  
  <p>I would like to combine lines 10 to 20 of all files in to a combined folder:</p>
  
  <pre><code>combined/foo.dat
  combined/bar.dat
  combined/qax.dat
  </code></pre>
  
  <p>Each of the files in combined have 30 lines, with 10 each from seed1,seed2 and seed3. </p>