apb*_*att 4 unix linux bash envsubst
我正在尝试运行命令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"
Run Code Online (Sandbox Code Playgroud)
这是我的结果:
$ 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!)
$
Run Code Online (Sandbox Code Playgroud)
我显然做了一些明显错误的事情,我只是有一个愚蠢的怀疑,这是那些如此明显的事情之一,我在试图找到答案时必须使自己的谷歌搜索过于复杂化
该变量未导出,因此对任何命令都不可见。导出它。
SIGNOFF="Goodbye"
export SIGNOFF
envsubst < file
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2773 次 |
最近记录: |