1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-28 19:44:56 +02:00
tldr/pages/common/envsubst.md
Lucas Gabriel Schneider a5fe31bc47
multiple pages: format technical tokens (#5119)
Co-authored-by: bl-ue <54780737+bl-ue@users.noreply.github.com>
Co-authored-by: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
2021-01-31 12:05:18 -05:00

644 B

envsubst

Substitutes environment variables with their value in shell format strings. Variables 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_file}}

  • Replace environment variables in an input file and output to a file:

envsubst < {{path/to/input_file}} > {{path/to/output_file}}

  • Replace environment variables in an input file from a space-separated list:

envsubst '{{$USER $SHELL $HOME}}' < {{path/to/input_file}}