Arrays
Integer-indexed Arrays
Displaying Arrays
Expands to single word with the value of each array element separated by the first character of the IFS special variable:
printf "%s\n" "${BASH_VERSINFO[*]}"
Expands to each element in array to a separate word:
printf "%s\n" "${BASH_VERSINFO[@]}"
Get second and third elements from array (as single word or as separate words):
printf "%s\n" "${BASH_VERSINFO[*]:1:2}"
printf "%s\n" "${BASH_VERSINFO[@]:1:2}"
Length of Array
Display the number of elements in the array:
printf "%s\n" "${#BASH_VERSINFO[*]}"
Display the length of element #4 (counting from 0) in the array:
printf "%s\n" "${#BASH_VERSINFO[4]}"
Assigning Array Elements
Using the += operator: