diff --git a/knowledge base/envsubst.md b/knowledge base/envsubst.md new file mode 100644 index 0000000..74b5dc0 --- /dev/null +++ b/knowledge base/envsubst.md @@ -0,0 +1,18 @@ +# Envsubst + +Substitutes environment variables in shell format strings. + +## TL;DR + +```shell +envsubst < input.file +envsubst < input.file > output.file +``` + +```shell +$ cat hello.file +hello $NAME + +$ NAME='mek' envsubst < hello.file +hello mek +``` diff --git a/knowledge base/export all variables in a envfile.md b/knowledge base/export all variables in a envfile.md new file mode 100644 index 0000000..19bd4ff --- /dev/null +++ b/knowledge base/export all variables in a envfile.md @@ -0,0 +1,15 @@ +# Export all variables in an envfile + +## TL;DR + +```shell +set -o allexport +source envfile +set +o allexport +``` + +## Sources + +- [Set environment variables from file of key/value pairs] + +[set environment variables from file of key/value pairs]: https://stackoverflow.com/questions/19331497/set-environment-variables-from-file-of-key-value-pairs#30969768 diff --git a/knowledge base/get the environment of a process running in a container.md b/knowledge base/get the environment of a process running in a container.md new file mode 100644 index 0000000..3f920a7 --- /dev/null +++ b/knowledge base/get the environment of a process running in a container.md @@ -0,0 +1,19 @@ +# Get the environment of a process running in a container + +## TL;DR + +```shell +cat /proc/${PID}/environ + +# Container in kubernetes. +kubectl exec pod-name -- cat /proc/1/environ + +# Only works if the onboard `ps` is not from busybox. +ps e -p $PID +``` + +## Sources + +- [Get the environment variables of running process in container] + +[get the environment variables of running process in container]: https://unix.stackexchange.com/a/412730