On Wed, Mar 21, 2012 at 12:55:05PM -0600, Bill Gradwohl wrote:
> answer='012345'
> modifier='?/.'
> echo $answer ${answer//?/.} ${answer//${modifier}}
>
> address@hidden ycc# ./tst
> 012345 ...... 012345
> Is it because ${modifier} is considered the pattern only , and not the
> pattern plus the string?
Yes. Storing the search pattern and the replacement string in variables
is the standard way to work around things that otherwise don't work
at all.
imadev:~$ input="don't worry" search="'" replace='`'
imadev:~$ echo "${input//$search/$replace}"
don`t worry
imadev:~$ input=/usr/local/bin/bash search=/ replace='\'
imadev:~$ echo "${input//$search/$replace}"
\usr\local\bin\bash
In your (rightmost) example, you were searching for the string ?/. which
of course was not present in the input.