In a Bash script I would like to split a line into pieces and store them in an array.
The line:
Paris, France, Europe
I would like
I came across this post when looking to parse an input like: word1,word2,...
none of the above helped me. solved it by using awk. If it helps someone:
STRING="value1,value2,value3"
array=`echo $STRING | awk -F ',' '{ s = $1; for (i = 2; i <= NF; i++) s = s "\n"$i; print s; }'`
for word in ${array}
do
echo "This is the word $word"
done