6.7 数组变量

声明:

  1. $ mytest=(one two three four five)

引用其中元素:

  • 从0开始
$ echo ${mytest[2]}

显示所有元素:

$ echo ${mytest[*]}

改变某个位置的值:

$ mytest[2]=seven

删除其中某个值:

  • 清空该位置的值, 所有元素位置不变
$ unset mytest[2]

删除数组:

$ unset mytest

在脚本编程中不常用