title: How can I split a string based on a delimiter in bash?
body: <p>I've defined an array in a .sh file like so:</p>
  
  <pre><code>hosts=(NODE IPS)
  hosts[0]="1.110,Node-01"
  hosts[1]="1.111,Node-02"
  hosts[2]="1.112,Node-03"
  hosts[3]="1.113,Node-04"
  hosts[4]="1.114,Node-05"
  hosts[5]="1.115,Node-06"
  </code></pre>
  
  <p>How can I loop over the array, but split each index based on the commma, and store the value in a variable, something like this:</p>
  
  <pre><code>for index in ${!hosts[*]}
  do
      ip = ## some way to split the string, and get the left side of the index
      hostname = ## some way to split the string, and get the right side of the index
      ## do something with the above variables
      echo "IP: $ip HOSTNAME: $hostname"
  done
  </code></pre>
  
  <p>I'm using linux if this helps</p>