title: Bash- parse file into arrays
body: <p>i have this file</p>
  
  <pre><code>Seq1
  10 1 5
  10 2 6
  10 3 9
  Seq2
  15 2 7
  15 4 9
  15 8 12
  </code></pre>
  
  <p>i want to have arrays for each Seqs (Seq1, Seq2) like this:</p>
  
  <pre><code>2ndColumn=(1,2,3) 
  3rdColumn=(5,6,9)
  </code></pre>
  
  <p>i wrote this but it does not break the while loop..</p>
  
  <pre><code>#!/bin/bash
  2ndColumn=()
  3rdColumn=()
  while read line 
  do
  if [[ $line == S* ]] 
   echo "$line"
  else
   i=0
   while [[ $line != S* ]]
   do
    2ndColumn[i]="$(echo $line | cut -d\  -f2)"
    3rdColumn[i]="$(echo $line | cut -d\  -f3)"
    i=$((i+1))
    read line
   done
   echo "${2ndColumn[@]} and ${3rdColumn[@]}"
  fi
  done &lt; file
  exit 0
  </code></pre>
  
  <p>this script will iterate forever, it does not get out of while loop. please give a hand to this stupid humanbeing :(</p>