Array and associated array in Linux shell

Source: Internet
Author: User

Definition and assignment of arrays and associated arrays in Linux shell # method of defining arrays 1array_var = (12345) # define the array method 2array_var [0] = "nick1" array_var [1] = "nick2" array_var [2] = "nick3" # print the array element content of a specific index echo $ {array_var [0]} index = 5 echo $ {array_var [$ index]} # print all values of the array in the form of a list echo $ {array_var [*]} echo $ {array_var [@]} # both ways can # print the array length echo $ {# array_var [*]} define the method declare-Aass_array of the associated array # The following two methods can assign values to the array ass_array = ([index1] = val1 [index2] = val2) ass_array [index1] = val1ass_ar Ray [index2] = val2 listing the array indexes of the associated array # You can list the indexes in either of the following ways: echo $ {! Array_var [*]} echo $ {! Array_var [@]}

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.