遍历文本文件输出数组文件

cat t.txt
1 a
2 b
3 c

这是forwhile的实现

#/bin/sh


a(){
#IFS来处理分隔符
IFS=$'\n'

  for line in $(cat t.txt)
  do
    IFS=$' '
    arr=(${line})
    echo ${arr[1]} -- ${arr[0]}

  done
}

b(){
  cat t.txt|while read line
  do
  # echo $line
    arr=($line)
    echo "${arr[0]} ++++++ ${arr[1]}"
 done

}