[Bash] Extract a substring by offset and length

Created on November 30, 2026

Use Bash parameter expansion to extract part of a variable's value. The offset starts at 0.

text="abcdefghij"
echo "${text:2:4}"
cdef

:2:4 starts at the third character and takes four characters.

Bash