envsubst
看起来完全像我想使用的东西,但-v
选项让我有点惊讶。
虽然envsubst < template.txt
工作正常,但 option-v
不起作用:
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.1 (Maipo)
$ envsubst -V
envsubst (GNU gettext-runtime) 0.18.2
Copyright (C) 2003-2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Bruno Haible.
正如我所写,这不起作用:
$ envsubst -v < template.txt
envsubst: missing arguments
$ cat template.txt | envsubst -v
envsubst: missing arguments
我必须这样做才能使其工作:
TEXT=`cat template.txt`; envsubst -v "$TEXT"
也许它可以帮助某人。