Denys Vlasenko | f8ddbe1 | 2016-07-25 03:56:00 +0200 | [diff] [blame] | 1 | parameter=abcdef |
2 | offset=2 | ||||
3 | noffset=-2 | ||||
4 | echo "parameter '${parameter}'" | ||||
5 | echo "varoffset2 '${parameter:${offset}}'" | ||||
6 | echo "varoffset-2 '${parameter:${noffset}}'" | ||||
7 | echo "literal '2' '${parameter:2}'" | ||||
8 | # This is not inrpreted as ${VAR:POS{:LEN}}, | ||||
9 | # but as ${VAR:=WORD} - if VAR is unset or null, substitute WORD | ||||
10 | echo "literal '-2' '${parameter:-2}'" | ||||
11 | echo "literal ' -2' '${parameter: -2}'" |