Frontier Software

Builtins

mapfile-readarray

An early (buggy) attempt at reading output of grep into an array looked like this:

IFS=$'\n\b' read -ra venue <<< "$(grep -Fwio -f /usr/local/share/dict/venues <<< "${location_arr["\"name\""]}")"

This was wrong because read expects a single line, and grep can output several. Another I thing I learnt was process substitution rather than overusing here strings.

mapfile -t venue < <(grep -Fwio -f /usr/local/share/dict/venues <<< "${location_arr["\"name\""]}")

This default behaviour is courtesy of an environment variable IFS (internal field separator) which comes set to space, TAB, NEWLINE. If you wanted to split a row (aka line of text) from a CSV file, you could use this combination of IFS and read.

echo

read