envsubst

Substitutes shell format strings with environment variables in text. Strings to be replaced should be in either `${var}` or `$var` format.

Install

All systems
curl cmd.cat/envsubst.sh
Debian Debian
apt-get install gettext-base
Ubuntu
apt-get install gettext-base
Alpine
apk add gettext
Arch Arch Linux
pacman -S gettext
image/svg+xml Kali Linux
apt-get install gettext-base
CentOS
yum install gettext
Fedora
dnf install gettext
OS X
brew install gettext
Raspbian
apt-get install gettext-base
Docker
docker run cmd.cat/envsubst envsubst powered by Commando

Substitutes shell format strings with environment variables in text. Strings to be replaced should be in either `${var}` or `$var` format.

  • Replace environment variables in stdin and output to stdout:
    echo '$HOME' | envsubst
  • Replace environment variables in an input file and output to stdout:
    envsubst < path/to/input
  • Replace environment variables in an input file and output to a file:
    envsubst < path/to/input > path/to/output
  • Replace environment variables in input from a space-separated list:
    envsubst variables < path/to/input

© tl;dr; authors and contributors