Forrest logo
back to the envsubst tool

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

The command envsubst '${$USER $SHELL $HOME}' < ${path-to-input_file} is used to substitute environment variables in a given input file.

Here's a breakdown of the command:

  1. envsubst: This is the command used to perform the environment variable substitution. It reads the input file and replaces the occurrences of environment variables with their corresponding values.

  2. '${$USER $SHELL $HOME}': This is a list of environment variables enclosed in single quotes. In this case, it includes the variables $USER, $SHELL, and $HOME. These variables will be replaced with their respective values in the input file.

  3. < ${path-to-input_file}: This indicates that the input file for the envsubst command is provided. ${path-to-input_file} should be replaced with the actual path to the input file.

So, by running this command, the content of the input file will be processed, and any occurrences of the specified environment variables will be replaced with their values.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the envsubst tool