function::env_var - Linux


env_var is a versatile Linux utility used for managing and setting environment variables. It allows customization of the environment in which processes and scripts execute, influencing their behavior and access to specific variables.


env_var [OPTION]... [-A] [-e] [--] [env_var [=value]]...


  • -A, –append: Append new values to existing environment variables instead of overwriting them.
  • -e, –erase: Erase specified environment variables from the environment.
  • -h, –help: Display usage information and exit.
  • -P, –prepend: Prepend new values to existing environment variables instead of appending them.


Set or modify an environment variable:

env_var FOO=BAR

Erase an environment variable:

env_var -e FOO

Append or prepend values to an environment variable:


Common Issues

Conflicting variable values: If multiple values for an environment variable are set using env_var, the last set value takes precedence.

Syntax errors: If an incorrect syntax is used, for instance, missing the assignment operator (=), the command will display an error and exit.


env_var can be combined with other Linux commands to modify the environment before running them:

env_var FOO=BAR ./

Related Commands

  • setenv: Sets environment variables for the current shell only.
  • printenv: Prints the current environment variables.
  • export: Exports variables from the current shell to child processes.