# Define an array my_array=("Element 1" "Element 2" "Element 3") # Set the IFS (Internal Field Separator) to comma IFS=',' # Collapse the array into a string collapsed_string="${my_array[*]}" # Print the collapsed string echo "$collapsed_string"
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter