将整个文件读入数组

阅读一步:

IFS=$'\n' read -r -a arr < file

循环阅读:

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

Version >= 4.0

使用 mapfile 或 readarray(它们是同义词):

mapfile -t arr < file
readarray -t arr < file