Toarray

toarray

Collect stdin into a named array, for use as the last command in a pipeline. Requires bash 4.2+ (lastpipe, enabled at load time).

Example

printf '%s\n' a b c | toarray myarr
printf '%s\n' "${myarr[@]}"
# => a
# => b
# => c

Arguments

  • $1 (string): Name of the array variable.

Exit codes

  • 0: Always