How can I control how an array separates its elements? If you do:
echo ${array[*]}
it displays:
element1 element2 element3
and I would like it to be:
element1:element2:element3
How can I control how an array separates its elements? If you do:
echo ${array[*]}
it displays:
element1 element2 element3
and I would like it to be:
element1:element2:element3
Elements are joined by the first character of $IFS
(internal field separator).
(IFS=':'; echo "${array[*]}")
Modifying $IFS
has a lot of side effects. I recommend only changing it for a short duration inside a subshell so the rest of your script isn't affected.