title: Is there a way to split an array of strings into multiple other arrays within Bash?
body: <p>I have an array <code>my_array</code> in Bash that contains string elements formatted as such</p>
  
  <pre><code>my_array[0] = "username_1:id_1:name_1"
  my_array[1] = "username_2:id_2:name_2"
  my_array[2] = "username_3:id_3:name_3"
  </code></pre>
  
  <p>I was curious if there is a convenient way to iterate through this array splitting it on the ":" character and storing the values into three separate arrays. The pseudo-code might look something like this</p>
  
  <pre><code>index=0
  for i in "${my_array}"
  do
     usernames[$index], ids[$index], names[$index]= $(echo $i | tr ":" "\n")
     (( index = index + 1 ))
  done
  </code></pre>
  
  <p>This question (<a href="https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash">How do I split a string on a delimiter in Bash?</a>) is very similar to what I am trying to accomplish, however I am trying to store the values into three different arrays which is my main obstacle. Thanks in advance for any help as I am extremely new to bash programming. </p>
  
  <p>here is what I have attempted:</p>
  
  <pre><code>
  index=0
  for i in "${arrayAdmin[@]}"
  do
          credentials=$(echo $i | tr ":" "\n" )
  
          accounts[$index]=${credentials[0]}
          groups[$index]=${credentials[1]}
          names[$index]=${credentials[2]}
          (( index = $index + 1))
          echo $index
  done
  </code></pre>