arrays API Reference
Bash indexed arrays — one-dimensional, sparse, integer-indexed collections of strings.
arrays
Bash indexed array operations: declaration, access, iteration and slicing.
arr=(a b c)Declares an indexed array by assigning a list of values enclosed in parentheses.
Returns: array
${arr[index]}Returns the element at the given integer index (0-based).
Returns: string
${arr[@]}Expands to all elements of the array as separate quoted words. Use [*] for a single word.
Returns: string list
${#arr[@]}Returns the number of assigned elements in the array (not the highest index).
Returns: integer
arr+=(d e)Appends one or more elements to the end of an existing indexed array.
Returns: array
unset arr[index]Removes the element at the given index. The array becomes sparse; indices are not shifted.
Returns: void
${arr[@]:start:count}Returns a slice of count elements starting at index start.
Returns: string list