export

verb

say it: “ek-SPORT” /ɪkˈspɔrt/

A shell command that hands a variable on to every program started from that shell, so those programs can read it too.

What does export do?

export is a shell builtin that turns a shell variable into an environment variable: every program you start from that shell gets a copy of it. A variable that isn't exported stays in your shell, where no program can see it. export lasts until the window closes; put the line in ~/.bashrc to have it in every new terminal.

POWER=on
bash kettle-bot      # the kettle-bot sees no POWER
export POWER
bash kettle-bot      # now it does

In a sentence

  • “After Sam ran export POWER, the kettle-bot script could finally see that POWER was on.”
  • “Adding export PATH="$PATH:$HOME/tools" to ~/.bashrc made the tools folder part of every new terminal.”

Level: Apprentice · More Unix terms at this level

Updated