Reading an entire file into an array
suggest changeReading in a single step:
IFS=$'\n' read -r -a arr < file
Reading in a loop:
arr=() while IFS= read -r line; do arr+=("$line") done
Using mapfile
or readarray
(which are synonymous):
mapfile -t arr < file readarray -t arr < file
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents