title: Split one big array into three
body: <p>I need to split one big array into three small ones. What I've tried:</p>
  
  <pre><code>#!/bin/bash
  declare -a bigarray
  bigarray=( 0 1 2 3 4 5 6 7 8 9 10 11 )
  total=${#bigarray[@]}
  let t1="$total / 3"
  declare -a fstsmall
  fstsmall=( "${bigarray[@]:0:$t1}" )
  let t2="$total - $t1 - 1"
  declare -a sndsmall
  sndsmall=( "${bigarray[@]:$t1:$t1}" )
  let t3="$t2 + 1"
  let theend="$total - $t2"
  echo $theendwq
  trdsmall=( "${bigarray[@]:$t3:$theend}" )
  echo "${fstsmall[@]}"
  echo "${sndsmall[@]}"
  echo "${trdsmall[@]}"
  exit 0
  </code></pre>
  
  <p>This is fine, it returns me:</p>
  
  <pre><code>0 1 2 3
  4 5 6 7
  8 9 10 11
  </code></pre>
  
  <p>But if I add 12th element to big array, it broke into:</p>
  
  <pre><code>0 1 2 3
  4 5 6 7
  9 10 11 12
  </code></pre>
  
  <p>8th element is omitted. I suspect I need for loops for this, since number of elements is dynamic.</p>