On Wed, 20 Aug 2014 15:05:48 +0200, eckard.bra...@gmx.de wrote: > Description: > Substring Expansion actually works different than manpage states, > namely: > > "If offset evaluates to a number less than zero, the value is > used as an offset from the end of the value of parameter." > > Repeat-By: > x="abcdef"; echo "${x:-2}" > Expected: ef > Got: abcdef > > or: > x="abcdef"; echo "${x:-2:1}" > Expected: e > Got: abcdef
One line below it also says: "Note that a negative offset must be separated from the colon by at least one space to avoid being confused with the :- expansion." $ x="abcdef"; echo "${x: -2}" ef $ x="abcdef"; echo "${x: -2:1}" e -- D.