shell-数组合并

定义

将两个数组或以上的元素连接到一起,变成一个新的大数组,语法为:
newarray=("${array1[@]}" "${array2[@]}")
中间要用空格隔开

实例

#!/bin/bash
program=(c c++ c# h5 java SQL python PHP perl go .net js MATLAB)
shell=(bash csh ksh rsh sh rc tcsh)
linux=(centos redhot ubuntu fedora suse )
newprogram=("${program[@]}" "${shell[@]}" "${linux[@]}")
echo ${newprogram[@]}
                          

结果为:

posted @ 2020-06-05 00:19  徐野子  阅读(1561)  评论(0编辑  收藏  举报