我正在尝试运行命令envsubst < myfile
来替换环境变量,但不是用它们的值替换,而是用空白字符串替换它们。
这是我的示例命令(为了清楚起见,分成单独的行):
SIGNOFF="Goodbye"
&&
printf "\nOkay, \$SIGNOFF has been set to \"$SIGNOFF\"\n\nOriginal contents:\n\n"
&&
cat test.conf
&&
printf "\n\nContents after envsubst < test.conf\n\n"
&&
envsubst < test.conf | cat
&&
printf "\n\n"
这是我的结果:
$ SIGNOFF="Goodbye" && printf "\nOkay, \$SIGNOFF has been set to \"$SIGNOFF\"\n\nOriginal contents:\n\n" && cat test.conf && printf "\n\nContents after envsubst < test.conf\n\n" && envsubst < test.conf | cat && printf "\n\n"
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!)
$
我显然在做一些明显错误的事情,我只是愚蠢地怀疑这是其中一件如此明显的事情,以至于我必须过于复杂自己的谷歌搜索来试图找到答案