parameter-expansion
Bash array slice
For nonnegative offset and length in indexed arrays, selects up to length existing values beginning at or after offset.
Formal Syntax & Structure
bash syntaxbash
"${name[@]:offset:length}"Return Value
words
For nonnegative offset and length in indexed arrays, selects up to length existing values beginning at or after offset.
Working Example
Example Snippetbash
items=([0]=a [3]=b [8]=c [9]=d)printf '%s\n' "${items[@]:2:2}"