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
I would echo the array as a string, then transform the spaces into line feeds, and then use paste to join everything in one line like so:
paste
tr " " "\n" <<< "$FOO" | paste -sd , -
Results:
This seems to be the quickest and cleanest to me !