printenv

Print the value of specific environment variables.

low risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
What it does

printenv prints the values of specified environment variables, or all variables if none are specified. Unlike env, it's purpose-built for querying — cleaner for scripting than parsing env output.

Examples
printenv HOMEPrint the home directory path · explain & risk-check →
printenv PATHPrint the current PATH · explain & risk-check →
printenv | sortList all env vars alphabetically · explain & risk-check →
printenv KUBECONFIG 2>/dev/null || echo 'Not set'Safely check if a var is set · explain & risk-check →
Pro tip

In scripts, prefer `printenv VAR` over `echo $VAR` — the latter can be confusing if the variable contains special characters.

Related
env export echo
Open the full explainer →More in Shell & Scripting

Reference text is hand-written and may be incomplete — check man printenv for your version. Test destructive commands on a non-production system first.