Shell Transfer Array Parameters!

Source: Internet
Author: User

Knowledge Points:

    1. Array

    2. function Local Variables

    3. Defining pass-through parameters


Example 1:

A= (1 2 3) b= (a B c) function () {Local a=$1 local b=$2 for I in $a does echo $i done Ech o $b}funcition "${a[*]}" "${b[*]}" Result: 123a b C difference: ${a[*]} is passed in a parameter, "1 2 3" ${a[@]} is passed in multiple parameters, "1", "2", "3"


Example 2:650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background-image:url ("/e/u261/lang /zh-cn/images/localimage.png "); background-position:center;background-repeat:no-repeat;border:1px solid RGB ( 221,221,221); "alt=" Spacer.gif "/>

If A= (1 2 3), $a represents the first element, you can use ${a[*]} or ${a[@]}

If A= "1 2 3", you can use ${a[*]} or ${a[@]} or $ A

If A= "1 2 3", array= ($a), Equals a= (1 2 3), Test echo ${array[@]}

For ((i=0,i<${#array [@]}, i= $i + 1)) Doecho ${array[$i]) done



# # Number of Arrays ${#array [@]}

# # array element replacement array[1]= "22"


This article from the "Technology blog" blog, declined to reprint!

Shell Transfer Array Parameters!

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.