[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转载于:https://blog.51cto.com/charlie928/1344122
bash脚本中数组操作详解
1231

被折叠的 条评论
为什么被折叠?



