Simple usage of array under linux

  1. Array assignment method

 

One is: array_name = (abcd) (Note: The elements are separated by spaces, not commas)

The other is: array_name [0] = a

                        array_name[1]=b

array_name[2]=c

array_name[3]=c

 

        2 Array call

   ${array_name[0]}

   ${array_name[1]}

3 Get all elements in the array

  ${array_name[@]}

 ${array_name[*]}

4 Get the number of elements in the array         

 ${#array_name[@]}

 

 ${#array_name[*]}

 

 

Guess you like

Origin www.cnblogs.com/wa-zz/p/12714972.html