arr=(a b c d e f g)
echo "${arr[@]:2}" # c d e f g — from index 2 to end
echo "${arr[@]:2:3}" # c d e — 3 elements starting at index 2
echo "${arr[@]:0:1}" # a — first element only
echo "${arr[@]: -2}" # f g — last 2 (note the space before -)
Create a free account and build your private vault. Share publicly whenever you want.