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"
也许对某人有帮助。