Forrest logo
tool overview
On this page you find all important commands for the CLI tool envsubst. If the command you are looking for is missing please ask our AI.

envsubst

The envsubst command line tool is used to substitute the values of environment variables into a given text file. It is commonly used in shell scripts or command pipelines to dynamically generate configuration files or templates.

When executed, envsubst scans the input file for variable references in the form of $VAR or ${VAR} and replaces them with the corresponding values from the environment. If a referenced variable is not set, it is replaced with an empty string.

For example, if MY_VAR=hello is an environment variable and you have a text file containing the line Welcome to $MY_VAR!, running envsubst < file.txt will replace $MY_VAR with hello, resulting in Welcome to hello!.

By using envsubst, you can efficiently create configuration files that adapt to different environments or change dynamically based on the values of environment variables.

List of commands for envsubst:

  • envsubst:tldr:a22ca envsubst: Replace environment variables in an input file from a space-separated list.
    $ envsubst '${$USER $SHELL $HOME}' < ${path-to-input_file}
    try on your machine
    explain this command
  • envsubst:tldr:a71ad envsubst: Replace environment variables in an input file and output to `stdout`.
    $ envsubst < ${path-to-input_file}
    try on your machine
    explain this command
  • envsubst:tldr:c373b envsubst: Replace environment variables in an input file and output to a file.
    $ envsubst < ${path-to-input_file} > ${path-to-output_file}
    try on your machine
    explain this command
tool overview