用重定向而不是管道,举例:-(dearvoid@LinuxEden:Forum)-(~/tmp)-
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[31048 0] ; cat file.sh
#!/bin/bash
arr=()
i=0
while read line; do
arr[i++]=$line
done < file
echo ${#arr[@]}
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[31048 0] ; ./file.sh
5