前一个月有阵子在写Bash Script, 这里记录下。
第一种是错误的写法
cat test.dat | while read line
do
array[$index]=$line
index=index+1
done
#echo array here
在上面的写法中,你会输出一堆空数组
正确的写法:
while read line
do
array[$index]=$line
index=$index+1
done < test.dat
#echo array here