1

输入:1 -> 2

while read -a line; do

  if (( line[2] < 1 )); then
    echo "Graph does not match known sites3"
    exit
  fi

done < "$2"

错误

syntax error: invalid arithmetic operator (error token is "")

由于某种原因 line[2] 不被视为数字 2 ......我该如何解决这个问题?

4

1 回答 1

3

要获取最后一个数组元素:

$ x=( a z e r t y)
$ echo ${x[-1]}
y
于 2012-12-30T12:12:47.207 回答