title: Looping through the contents of a file, extracting data between two identifiers/tags
body: <p>I want to divide one very large file into a number of smaller ones. Then I want to save each smaller file to its own directory.  I'm not familiar with Awk or Bash scripting.</p>
  
  <p>My large data file has the structure shown below.  In it, "i" is a time step and "9" refers to the number of rows (data points) in each time step.  </p>
  
  <p>For each time step, I want to take everything (i.e., from and including "9" to the line above the next "9") and put it in its own file and own directory labeled according to the time step.  I would be very grateful for any advice.  If the question is not clear, I would be happy to modify it.</p>
  
  <pre><code>     9
  i =        0
  Ir         2.7122680189       11.056957424         6.8765696187
  Ir         1.7122680189        7.0569574242        2.8765696187
  Ir         10.1738894899      10.9594639697       10.1225475792
  Ir         1.7122680189       10.5695742424        2.8765696187
  Ir         0.8778827417       -0.5336942397        0.4088988234
  XO         0.1738894899        6.9594639697       -2.1225475792
  XO        -8.0921793354        6.4673780979        2.6251511813
  XO        -5.1738894899       -0.9594639697       -7.1225475792
  XO         4.1738894899       -7.9594639697       12.1225475792
       9
  i =        1
  Ir         2.7122680189       11.056957424         6.8765696187
  Ir         1.7122680189        7.0569574242        2.8765696187
  Ir         10.1738894899      10.9594639697       10.1225475792
  Ir         1.7122680189       10.5695742424        2.8765696187
  Ir         0.8778827417       -0.5336942397        0.4088988234
  XO         0.1738894899        6.9594639697       -2.1225475792
  XO        -8.0921793354        6.4673780979        2.6251511813
  XO        -5.1738894899       -0.9594639697       -7.1225475792
  XO         4.1738894899       -7.9594639697       12.1225475792
  </code></pre>
  
  <p>I have been able to figure out (roughly) how to make new directories for each time and copy other files I need into them, but not how to put my files of interest into them. E.g.</p>
  
  <pre><code>let TIMESTEPS=100000 
  for ((time=0; time &lt;= TIMESTEPS; time++)) 
  do
       mkdir -p $time/timeData
       cp otherUsefulFile $time/
  done
  </code></pre>