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
brew install gettext
then modify .bashrc:
yum install -y gettext