I am trying to use bash string operators in a constant string. For example, you can do the following in the variable $ foo:
$ foo=a:b:c; echo ${foo
c
Now, if the string "a: b: c" is constant, I would like to have a more concise solution, for example:
echo ${"a:b:c"
However, this is not valid bash syntax. Is there any way to accomplish this?
[The reason I need to do this (instead of hard-coding the substitution result, that is, "c" here) is because I have a command template where the substitute "% h" is replaced with something before running the command ; the substitution result is considered a constant in bash.]
source
share