2017-07-06 23:18:20 +05:30
|
|
|
parameter=abcdef
|
|
|
|
offset=2
|
|
|
|
noffset=-2
|
|
|
|
echo "parameter '${parameter}'"
|
|
|
|
echo "varoffset2 '${parameter:${offset}}'"
|
|
|
|
echo "varoffset-2 '${parameter:${noffset}}'"
|
|
|
|
echo "literal '2' '${parameter:2}'"
|
2017-07-06 23:20:42 +05:30
|
|
|
# This is not interpreted as ${VAR:POS{:LEN}},
|
2017-07-06 23:18:20 +05:30
|
|
|
# but as ${VAR:=WORD} - if VAR is unset or null, substitute WORD
|
|
|
|
echo "literal '-2' '${parameter:-2}'"
|
|
|
|
echo "literal ' -2' '${parameter: -2}'"
|