LINUX.ORG.RU

       ${parameter:offset}
       ${parameter:offset:length}
              Substring Expansion. ...
              If offset evaluates to a number less than zero, the value is
              used  as an offset from the end of the value of parameter.  Arithmetic expressions starting with a - must be
              separated by whitespace from the preceding : to be distinguished from the Use Default Values expansion.

И в результате должно быть не ab, а c.

watashiwa_daredeska ★★★★
()

${parameter:-word} Use Default Values. If parameter is unset or null, the expansion of word is substituted; otherwise, the value of parameter is substituted.

dilmah ★★★★★
()

$ a='123456'
$ echo ${a:2}
3456
$ echo ${a:(-2)}
56
$ echo ${a:-2}
123456
unset a
$ echo ${a:-2}
2

sdio ★★★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.