How do I join an array of strings where each string has spaces?
5
votes
3
answers
3894
views
My bash script:
#!bin/bash
MY_ARRAY=("Some string" "Another string")
function join { local IFS="$1"; shift; echo -e "$*"; }
join "," ${MY_ARRAY[@]}
I want the output to be:
Some string,Another string
.
Instead, I get Some,string,Another,string
.
What must I change to get the result I want?
Asked by Username
(899 rep)
Aug 30, 2017, 10:22 PM
Last activity: Jul 17, 2025, 06:30 AM
Last activity: Jul 17, 2025, 06:30 AM