1. Copying and fetching values
Assign Value #!/bin/basharry_name= (xiaoming xiaoli dalong Sanlang) echo ${arry_name[0]}echo ${arry_name[1]}echo ${arry_name[2] }echo ${arry_name[3]}[[email protected] ~]# bash Arry.shxiaomingxiaolidalongsanlang[[email protected] ~]#
assign values individually [[email protected] ~]# vim arry02.shname[0]= "xiaoming" name[2]= "Xiaoli" name[3]= "Lusa" Echo ${name[0]}echo ${name[1 ]}echo ${name[2]}~ [[email protected] ~]# bash arry02.shxiaoming xiaoli[[email protected] ~]# name[0]= "Xiaoming" [[Email P Rotected] ~]# echo ${name[0]}xiaoming[[email protected] ~]#
2. Get the length of a string
[Email protected] ~]# name= "Oldboy" [[email protected] ~]# echo ${#name}6[[email protected] ~]#
3. Get the length of the array
[email protected] ~]# cat arry02.shname[0]= "Xiaoming" name[2]= "Xiaoli" name[3]= "Lusa" Echo ${name[0]}echo ${name[1]} echo ${name[2]}echo ${#name [*]}echo ${#name [@]}[[email protected] ~]#[[email protected] ~]# bash arry02.shxiaoming xiaol I33
For loop values
[email protected] ~]# cat arr.sharry= (10.0.0.110.0.0.210.0.0.310.0.0.4) for I in ${arry[*]}do echo $idone [[Email Protected] ~]#[[email protected] ~]# bash arr.sh10.0.0.110.0.0.210.0.0.310.0.0.4
#!/bin/basharry= (10.0.0.010.0.0.110.0.0.2) for ((i=0;i<${#arry [*]};i++)] do echo ${arry[$i]}done~
The value of the FETCH command
The command results are placed inside the array: arry= (LS) [[email protected] ~]# cat a.sh#!/bin/basharry= ($ (LS)) for i in ${arry[*]}do echo $idone [[Email Protected] ~]#
Reflections on the value of Arry:
1. Go directly to Arry ${arry[*]}
2.for Loop Gets the length, by index the value of the output array
This article is from the "Brick Blog" blog, please be sure to keep this source http://wsxxsl.blog.51cto.com/9085838/1825932
Shell Programming Arry Arrays