The bash builtin mapfile reads from standard input and copies lines to the given array (the -t option removes the newline).
I can't figure out why it works in the first case below but not the second:
Code:$ echo -e "one\ntwo\nthree" > tempfile; mapfile -t an_array1 < tempfile $ echo ${an_array1[1]} two $ echo -e "one\ntwo\nthree" | mapfile -t an_array2 $ echo ${an_array2[1]} <-- doesn't print anything $ echo ${#an_array2[*]} # print array length 0