Bash Read a file (data stream, variable) line-by-line (and/or field-by-field)? Read lines of a file into an array


Example

readarray -t arr <file

Or with a loop:

arr=()
while IFS= read -r line; do
   arr+=("$line")
done <file