Is there a way to prevent envsubst
from substituting a $VARIABLE
? For example, I would expect something like:
export THIS=THAT echo "dont substitute \\\$THIS" | envsubst
and have it return
dont substitute $THIS
but instead I get
dont substitute \THAT
is there any escape character for doing this?
If you give envsubst
a list of variables, it only substitutes those variables, ignoring other substitutions. I'm not exactly sure how it works, but something like the following seems to do what you want:
$ export THIS=THAT FOO=BAR $ echo 'dont substitute $THIS but do substitute $FOO' | envsubst '$FOO' dont substitute $THIS but do substitute BAR
Note that $THIS
is left alone, but $FOO
is replaced by BAR
.
export DOLLAR='$' export THIS=THAT echo '${DOLLAR}THIS' | envsubst
Or more clear:
export THIS=THAT echo '${DOLLAR}THIS' | DOLLAR='$' envsubst
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With