1, 定义数组
arr=(1 2 3)
arr2=("a" "b" "c")
2, 获取基本数据:arrLen,arr[i]
3, 遍历元素
4,数组+ 文件内容读取
[root@c72 ~]# cat a.txt
123
456
x
yyy
[root@c72 ~]# arr=()
[root@c72 ~]#
while read line ;
do echo $line;
arr+=($line);
done < a.txt ;
123
456
x
yyy
[root@c72 ~]# for i in ${arr[@]}; do echo $i; done
123
456
x
yyy
[root@c72 ~]#
#字符串拼接
[root@c72 ~]#
pulled=;
while read line ;
do echo $line;
pulled="$pulled $line";
done < a.txt ;
echo $pulled
123
456
x
yyy
123 456 x yyy
[root@c72 ~]#