[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