printenv — Display the values of environment variables

Format

printenv [name]

tcsh shell: printenv [name]

Description

The printenv command displays the values of environment variables. If the name argument is specified, only the value associated with name is printed. If it is not specified, printenv displays the current environment variables, one name=value pair per line.

If a name argument is specified but is not defined in the environment variable, printenv returns exit status 1; otherwise it returns status 0.

In the tcsh shell, printenv prints the names and values of all environment variables or, with name, the value of the environment variable named. For more information, see tcsh — Invoke a C shell.

Options

There are no options.

Examples

To find the current setting of the HOME environment variable, enter:
printenv HOME

Usage notes

  1. Only one name argument can be specified.
  2. printenv SOMENAME is equivalent to echo $SOMENAME for exported variables.
  3. printenv without any arguments is functionally equivalent to env without any arguments.

Exit values

0
Successful completion
1
Failure due to one of the following:
  • More than one environment variable was specified
  • An option was specified (printenv has no options)

Portability

printenv is compatible with the AIX® printenv utility.

Related information

env, tcsh