为什么我的envsubst命令只是插入空白字符串



我试图运行命令envsubst < myfile来替换环境变量,但它们不是用它们的值替换的,而是用空白字符串替换的。

以下是我的示例命令(为了清晰起见,拆分为单独的行):

SIGNOFF="Goodbye"
&&
printf "nOkay, $SIGNOFF has been set to "$SIGNOFF"nnOriginal contents:nn"
&&
cat test.conf
&&
printf "nnContents after envsubst < test.confnn"
&&
envsubst < test.conf | cat
&&
printf "nn"

以下是我的结果:

$ SIGNOFF="Goodbye" && printf "nOkay, $SIGNOFF has been set to "$SIGNOFF"nnOriginal contents:nn" && cat test.conf && printf "nnContents after envsubst < test.confnn" && envsubst < test.conf | cat && printf "nn"
Okay, $SIGNOFF has been set to "Goodbye"
Original contents:
Hello world, let's change the variable in the quotes below to say Goodbye!
"$SIGNOFF" (it certainly shouldn't just be blank!)
Contents after envsubst < test.conf
Hello world, let's change the variable in the quotes below to say Goodbye!
"" (it certainly shouldn't just be blank!)
$ 

我显然做错了什么,我只是有一个愚蠢的怀疑,这是一件非常明显的事情,我一定是在试图找到答案时过度复杂化了我自己的谷歌搜索

变量不导出,因此它对任何命令都不可见。导出。

SIGNOFF="Goodbye"
export SIGNOFF
envsubst < file

相关内容

  • 没有找到相关文章

最新更新