builtin-option
Bash read -a
Reads a record and splits fields according to IFS into an indexed array, clearing previous elements first; not a CSV parser.
Formal Syntax & Structure
bash syntaxbash
read -r -a nameReturn Value
exit status
Reads a record and splits fields according to IFS into an indexed array, clearing previous elements first; not a CSV parser.
Working Example
Example Snippetbash
read -r -a fields < <(printf '%s\n' 'red green blue')printf 'count=%s\n' "${#fields[@]}"printf '[%s]\n' "${fields[@]}"