Bash: Turn a string into an array

August 13, 2010   

I needed to turn a string into an array to loop through it. It is pretty simple

SOLR_CORES="core1,core2,core3"
declare -a CORES
CORES=(`echo $SOLR_CORES | tr ',' ' '`)       

for CORE in ${CORES[@]}
do
    stuff here
done


comments powered by Disqus