[Bash] Take a range of elements from an array

Created on November 30, 2026

Use an array expansion with an offset and a length. This example takes three values starting at index 1.

items=(zero one two three four)
printf '%s\n' "${items[@]:1:3}"
one
two
three

The indexes start at 0. Keep the expansion inside double quotes so each selected value is a separate argument.

Reference

Bash Shell command