Created
December 21, 2020 19:01
-
-
Save mehmetahsen/299f4157a839481bbfdd3b6100ab2ed2 to your computer and use it in GitHub Desktop.
envsubst vs bash here-doc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# With envsubst | |
# | |
$ cat webadmin.ini.tpl # a template file is required | |
[User:${CUBERITE_USERNAME}] | |
Password=${CUBERITE_PASSWORD} | |
[WebAdmin] | |
Enabled=1 | |
Ports=8080 | |
$ export CUBERITE_USERNAME=admin #vars need to be exported | |
$ export CUBERITE_PASSWORD=cuberite | |
$ envsubst < webadmin.ini.tpl > webadmin.ini # neat and tidy single liner | |
$ cat webadmin.ini # result | |
[User:admin] | |
Password=cuberite | |
[WebAdmin] | |
Enabled=1 | |
Ports=8080 | |
# | |
# with bash here-doc | |
# | |
$ CUBERITE_USERNAME=admin # vars need not to be exported | |
$ CUBERITE_PASSWORD=cuberite | |
$ cat <<EOF > webadmini.ini # crowded but no other file required | |
[User:${CUBERITE_USERNAME}] | |
Password=${CUBERITE_PASSWORD} | |
[WebAdmin] | |
Enabled=1 | |
Ports=8080 | |
EOF | |
$ cat webadmin.ini # result | |
[User:admin] | |
Password=cuberite | |
[WebAdmin] | |
Enabled=1 | |
Ports=8080 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment