commands

env — run with a modified environment

GNU env runs an external command with modified environment entries; without a command it prints environment values, which may contain secrets. Example assumes a fresh shell lab fixture with new output names.

Formal Syntax & Structure

linux syntaxlinux
env [OPTION]... [NAME=VALUE]... [COMMAND [ARG...]]

Parameters & Attributes

NameTypeDescription
NAME=VALUEoperandenvironment assignment
COMMANDoperandExternal executable; if omitted, prints the resulting environment (avoid exposing secrets).
ARGoperandarguments
-ioptionStart with an empty environment; then apply supplied assignments.

Return Value

exit status and output

GNU env runs an external command with modified environment entries; without a command it prints environment values, which may contain secrets.

Working Example

Example Snippetlinux
env BM_MODE=preview bash -c 'printf "%s\n" "$BM_MODE"'
Linux Reference