[root@10-6-8-200 test]# testarr=(a b c d e f) //字义数组
[root@10-6-8-200 test]# echo ${testarr[0]} //打印第一位数组
a
[root@10-6-8-200 test]# echo ${testarr[*]} //打印所有数组
a b c d e f
[root@10-6-8-200 test]# echo ${testarr[@]} //同上
a b c d e f
[root@10-6-8-200 test]# echo ${#testarr[@]} //打印数组的长度
6
[root@10-6-8-200 test]# echo ${#testarr[*]} //同上
6
#!/bin/bash
arr=(a b c d e f)
for ((i=0;i<${#arr[*]}-1;i++));
do      
        echo $i time:      
        for ((j=i+1;j<${#arr[*]};j++))      
        do              
                echo -n ${arr[$i]}${arr[$j]}" "      
        done      
        echo
done
[root@10-6-8-200 test]# bash test.sh
0 time:
ab ac ad ae af
1 time:
bc bd be bf
2 time:
cd ce cf
3 time:
de df
4 time:
ef