parameter-expansion
Bash array element access
Expands the assigned element at an integer index. Quote the expansion for ordinary command arguments.
Formal Syntax & Structure
bash syntaxbash
${name[index]}Return Value
string
Expands the assigned element at an integer index. Quote the expansion for ordinary command arguments.
Working Example
Example Snippetbash
declare -a items=(red 'dark blue')printf '%s\n' "${items[0]}" "${items[1]}"