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?
printf "%s,%s\n" "${MY_ARRAY[@]}"
– jasonwryan Aug 30 '17 at 22:24${MY_ARRAY[@]}"
. See also Why does my shell script choke on whitespace or other special characters? – Wildcard Aug 30 '17 at 22:26