Shell Programming Arry Arrays

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.