var="hello"
echo ${var:2} # Print from character 2
echo ${var:2:1} # Print 1 character from character 2
llo
l
Marie-Hélène Burle
Alex Razoumov
This section shows how to subset, search, replace, or concatenate strings simply using the Bash variable extraction syntax.
llo
l
Bash indexes from 0.
If you want to concatenate the expanded variable with another string, you need to use curly braces or quotes.
This does not return anything because there is no variable called varshine
:
These two syntaxes do work: