Friday, July 29, 2022

[SOLVED] is there an escape character for envsubst?

Issue

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?


Solution

export DOLLAR='$'

export THIS=THAT
echo '${DOLLAR}THIS' | envsubst

Or more clear:

export THIS=THAT
echo '${DOLLAR}THIS' | DOLLAR='$' envsubst


Answered By - iokanuon
Answer Checked By - Marie Seifert (WPSolving Admin)