1 回答
1
If you want to keep the single quotes, then you need '"'"'
The first quote ends the current single quoted string. Then we have "'" which expands to a single quote. \' would also work but doesn't look as good.
The last single quote starts the quoted string again.
An alternative in your case would be "s/ is /${r}'s${x}/g" (i.e. only use double quotes).
But then, you need to use r='\\e[0;31m' because the expansion in the string will string one level of escapes.
于 2013-11-13T16:43:37.357 回答