substring expansion

The ${name:offset:length} form, which takes part of a string starting at a zero-based offset.

In more detail

Leave out the length to run to the end of the string. A negative offset counts from the end but needs a space after the colon so it is not mistaken for the :- default form. The same form slices arrays.

Example

name=abcdef; echo "${name:1:3}"

Related terms

Taught in

References