Join
array_split¶
Split a string on a delimiter into a named array. The delimiter must be a single character.
Example¶
array_split myarr , "a,b,c,d"
printf '%s\n' "${myarr[@]}"
# => a
# => b
# => c
# => d
Arguments¶
- $1 (string): Name of the array variable.
- $2 (string): Single-character delimiter.
- $3 (string): The string to split.
Exit codes¶
- 0: Always
array_join¶
Join array elements with a delimiter and output a single string.
Example¶
array_join '|' a b c d
# => a|b|c|d
array_join '||||' a b c d
# => a||||b||||c||||d
testarray=( a 'b c' d e )
array_join ',' "${testarray[@]}"
# => a,b c,d,e
Arguments¶
- $1 (string): The delimiter string.
- ... (string): Elements to join, passed by value.
Exit codes¶
- 0: Success
- 1: No arguments given.
Output on stdout¶
- The joined string.