If I have an array like this in Bash:
FOO=( a b c )
How do I join the elements with commas? For example, producing a,b,c.
a,b,c
x=${"${arr[*]}"// /,}
This is the shortest way to do it.
Example,
arr=(1 2 3 4 5) x=${"${arr[*]}"// /,} echo $x # output: 1,2,3,4,5