我有这个文件
Seq1
10 1 5
10 2 6
10 3 9
Seq2
15 2 7
15 4 9
15 8 12
我想为每个 Seqs (Seq1, Seq2) 设置这样的数组:
2ndColumn=(1,2,3) 
3rdColumn=(5,6,9)
我写了这个,但它并没有打破while循环..
#!/bin/bash
2ndColumn=()
3rdColumn=()
while read line 
do
if [[ $line == S* ]] 
 echo "$line"
else
 i=0
 while [[ $line != S* ]]
 do
  2ndColumn[i]="$(echo $line | cut -d\  -f2)"
  3rdColumn[i]="$(echo $line | cut -d\  -f3)"
  i=$((i+1))
  read line
 done
 echo "${2ndColumn[@]} and ${3rdColumn[@]}"
fi
done < file
exit 0
该脚本将永远迭代,它不会退出 while 循环。请帮帮这个愚蠢的人:(