2025-03-14 21:59:59 -06:00
|
|
|
# envsubst
|
|
|
|
|
|
|
|
|
|
> Substitutes environment variables with their value in shell format strings.
|
|
|
|
|
> Variables to be replaced should be in either `${var}` or `$var` format.
|
2025-12-16 10:20:31 -07:00
|
|
|
> More information: <https://www.gnu.org/software/gettext/manual/gettext.html#envsubst-Invocation>.
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- 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:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`envsubst < {{path/to/input_file}} '{{$USER $SHELL $HOME}}'`
|