[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 2

env Command

Purpose

Displays the current environment or sets the environment for the execution of a command.

Syntax

To Display Multiple Environment Variables

env-i | - ] [Name=Value ]... [Command [ Argument ... ] ]

To Display A Single Environment Variable

env [Name]

Description

The env command allows you to display your current environment or run a specified command in a changed environment.

If no flags or parameters are specified, the env command displays your current environment, showing one Name=Value pair per line.

Flags

-i Ignores the inherited environment and invokes the command specified by the Command parameter with the environment specified by the Name=Value parameters.
- Obsolete flag. Use the -i flag.

Parameters

Name=Value You can run a command in a modified version of the current environment by specifying one or more Name=Value parameters. Use the -i flag if you wish to replace the entire current environment with the specified Name =Value parameters. In either case, environment changes are effective only while the specified command is running.
Command The Command parameter has an optional Argument variable. If the specified command is one of the Korn shell special built-in commands, results are unspecified. Korn shell built-in commands are described in the ksh command.

Exit Status

If the Command parameter is specified, the exit status of the env command is the exit status of the command specified in the Command parameter. Otherwise, the env command exits with one of the following values:

0 The env command completed successfully.
1-125 An error occurred in the env command.
126 The command specified by the Command parameter was found, but could not be invoked.
127 The command specified by the Command parameter was not found.

Examples

  1. To change the TZ environment variable while running the date command, type:

    TZ=MST7MDT date

    OR

    env TZ=MST7MDT date

    Each of these commands displays the time in mountain time and the current date. The two commands shown are equivalent. When the date command is finished, the previous value of the TZ environment variable takes effect again.

  2. To run the make command in an environment that consists only of definitions for the PATH, IDIR, and LIBDIR environment variables, type:

    env -i PATH=$PATH IDIR=/$HOME/include LIBDIR=/$HOME/lib make

    You must specify the PATH environment variable so that the shell can find the make command. When the make command is finished, the previous environment takes effect.

Files

/usr/bin/env Contains the env command.

Related Information

The printenv command, ksh command.

The environment file.

The profile file format.

The exec subroutines.

Commands Overview in AIX 5L Version 5.2 System User's Guide: Operating System and Devices.

Profiles Overview in AIX 5L Version 5.2 System Management Concepts: Operating System and Devices.

Shells Overview in AIX 5L Version 5.2 System Management Guide: Operating System and Devices.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]