On Fri, Feb 12, 2016 at 09:22:21AM +0100, Ulrich Windl wrote: > "X=ABC; echo ${X:-2}" outputs "ABC", and not "BC"
When using a negative index/offset, you have to separate it from the colon so that it is not interpreted as a ${var:-default} substitution. There are many ways to write it: ${x: -2} ${x:(-2)} ${x:0-2} offset=-2; ${x:offset} ... I prefer ${x:(-2)} myself, but they are all valid.