This question is more appropriate for help-bash than bug-bash. On Tue, Sep 17, 2024, at 2:21 AM, William Park wrote: > Hi all, > > Is there fast way of splitting and joining of strings in the recent Bash > versions?
Define "fast". > For splitting, I'm aware of > old="a,b,c" > IFS=, read -a arr <<< "$old" > > For joining, > new=$(IFS=,; echo "${arr[*]}") > or > new=$(IFS=,; echo "$*") A joining alternative that avoids subshells: printf -v new '%s,' "${arr[@]}" new=${new%?} Another: strjoin() { local IFS=$1 shift REPLY=$* } strjoin , "${arr[@]}" new=$REPLY -- vq