2018-04-12 17:39:43 +01:00
|
|
|
# envsubst
|
|
|
|
|
2019-08-07 06:32:59 +01:00
|
|
|
> Substitutes environment variables with their value in shell format strings.
|
|
|
|
> Variables to be replaced should be in either `${var}` or `$var` format.
|
2021-04-17 16:15:37 +01:00
|
|
|
> More information: <https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html>.
|
2018-04-12 17:39:43 +01:00
|
|
|
|
2021-01-31 17:05:18 +00:00
|
|
|
- Replace environment variables in stdin and output to stdout:
|
2018-04-12 17:39:43 +01:00
|
|
|
|
|
|
|
`echo '{{$HOME}}' | envsubst`
|
|
|
|
|
2021-01-31 17:05:18 +00:00
|
|
|
- Replace environment variables in an input file and output to stdout:
|
2018-04-12 17:39:43 +01:00
|
|
|
|
2019-08-07 06:32:59 +01:00
|
|
|
`envsubst < {{path/to/input_file}}`
|
2018-04-12 17:39:43 +01:00
|
|
|
|
|
|
|
- Replace environment variables in an input file and output to a file:
|
|
|
|
|
2019-08-07 06:32:59 +01:00
|
|
|
`envsubst < {{path/to/input_file}} > {{path/to/output_file}}`
|
2018-04-12 17:39:43 +01:00
|
|
|
|
2019-08-07 06:32:59 +01:00
|
|
|
- Replace environment variables in an input file from a space-separated list:
|
2018-04-12 17:39:43 +01:00
|
|
|
|
2019-08-07 06:32:59 +01:00
|
|
|
`envsubst '{{$USER $SHELL $HOME}}' < {{path/to/input_file}}`
|