Skip to content
Justice Tech School

Array Slices and Lengths

${a[@]:start:count} slices an array and ${#a[@]} counts items.

Example
a=(a b c d e)
echo "${a[@]:1:3}"
echo "${#a[@]}"
b=("${a[@]}" f)
echo "${b[@]}"

Result

b c d
5
a b c d e f

Exercise

Slice 2 items.

${a[@]:1:}

Quiz Test

What does ${a[@]:1:3} give?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.