skip to content
Pradeep Chhetri

Software Engineer. Writing about databases, infrastructure, and distributed systems.

Main navigation

  • Home
  • Blog
  • TIL
GitHub LinkedIn RSS

GNU Utility: Envsubst

November 5, 2020 · TIL

Tags:
  • tool

Recently, I learnt about a new command: envsubst which is present by default. It substitutes the values of environment variables. This means, instead of using helm, we can use plain k8s manifest and define environment specific variables and let envsubst replace them.

❯ cat foobar
PWD: ${PWD}
❯ envsubst < foobar
PWD: /Users/pradeep

Many a time, you may want to only substitue the values of envvars partly but not of all.

❯ cat foobar
foo: $FOO
bar: $BAR
❯ export FOO=foo
❯ export BAR=bar

Let say in above file, you only want to replace FOO’s value but don’t want to replace BAR’s value. You can achieve it:

❯ envsubst '$FOO' < foobar
foo: foo
bar: $BAR

© 2026 Pradeep Chhetri