De man bash
:
${parameter#word}
${parameter##word}Remove matching prefix pattern. The word is expanded to produce a pattern just as in pathname expansion. If the pattern matches the beginning of the value of parameter, then the result of the expansion is the expanded value of parameter with the shortest matching pattern (the
#
case) or the longest matching pattern (the##
case) deleted.
Seu padrão é *:*:*
e bash
tentará remover o prefixo correspondente mais curto:
-
OK:
para o primeiro*:
-
DriveC-ReadBytesPerSec:
para o segundo*:
- e nada para o último
*
, porque é a correspondência mais curta.
Compare:
$ # shortest match without surplus *
$ echo ${READRESULT#*:*:}
289283
$ # going for longest match now; the last * will swallow the number
$ echo ${READRESULT##*:*:*}
$ # longest match without the last *
$ echo ${READRESULT##*:*:}
289283
$ # no need to repeat *: because * matches everything before the last : anyway
$ echo ${READRESULT##*:}
289283