is there an escape character for envsubst?

后端 未结 6 1749
北海茫月
北海茫月 2020-12-29 01:28

Is there a way to prevent envsubst from substituting a $VARIABLE? For example, I would expect something like:

export THIS=THAT
echo         


        
6条回答
  •  佛祖请我去吃肉
    2020-12-29 01:43

    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.

提交回复
热议问题