Envsubst: Difference between revisions
Jump to navigation
Jump to search
(6 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
=Overview= | =Overview= | ||
<tt>envsubst</tt> performs [[ | <tt>envsubst</tt> performs [[Bash_Parameter_and_Variable_Expansion#Variable_Expansion_in_an_Arbitrary_File|environment variable expansion]] in shell-format strings in arbitrary files, by replacing [[Bash_Parameters_and_Variables#Global_Variable|global variables]] with their values. No other shell [[Bash Command Line Expansion#Overview|command line expansions]] will be. performed. If a variable is declared but not found in the environment, it will be replaced with the empty string. | ||
cat file.txt | envsubst > file-with-variables-expanded.txt | |||
=Installation= | =Installation= | ||
==Mac== | ==Mac== | ||
brew install gettext | |||
then modify .bashrc: | |||
export PATH=/usr/local/opt/gettext/bin:${PATH} | |||
==RedHat/Centos== | ==RedHat/Centos== | ||
yum install -y gettext |
Latest revision as of 10:10, 2 January 2021
Internal
Overview
envsubst performs environment variable expansion in shell-format strings in arbitrary files, by replacing global variables with their values. No other shell command line expansions will be. performed. If a variable is declared but not found in the environment, it will be replaced with the empty string.
cat file.txt | envsubst > file-with-variables-expanded.txt
Installation
Mac
brew install gettext
then modify .bashrc:
export PATH=/usr/local/opt/gettext/bin:${PATH}
RedHat/Centos
yum install -y gettext