[root@OBird shell]# vim fun.sh

#!/bin/bash

function mysum()    {

       sum=$[$1+$2]

       echo $sum

}

a=1

b=2

mysum $a $b


[root@OBird shell]# sh fun.sh 

3


[root@OBird shell]# sh -x fun.sh 

+ a=1

+ b=2

+ mysum 1 2

+ sum=3

+ echo 3

3



[root@OBird shell]# a=(1 2 3 4 5)

[root@OBird shell]# echo $a

1


[root@OBird shell]# echo ${a[@]}

1 2 3 4 5


[root@OBird shell]# echo ${a[4]}  #输出其中一个元素

5


[root@OBird shell]# a[6]=8  #定义元素


[root@OBird shell]# a[2]=9  #更改元素

[root@OBird shell]# echo ${a[@]} #再次输出

1 2 9 4 5 8

[root@OBird shell]# echo ${#a[@]}  #打印数组数量

6