Variables set by the Korn shell or POSIX shell

The following are variables that are set by the shell.


Item Description
underscore (_) Indicates initially the absolute path name of the shell or script being executed as passed in the environment. Subsequently, it is assigned the last argument of the previous command. This parameter is not set for commands that are asynchronous. This parameter is also used to hold the name of the matching MAIL file when checking for mail.
ERRNO Specifies a value that is set by the most recently failed subroutine. This value is system-dependent and is intended for debugging purposes.
LINENO Specifies the line number of the current line within the script or function being executed.
OLDPWD Indicates the previous working directory set by the cd command.
OPTARG Specifies the value of the last option argument processed by the getopts regular built-in command.
OPTIND Specifies index of the last option argument processed by the getopts regular built-in command.
PPID Identifies the process number of the parent of the shell.
PWD Indicates the present working directory set by the cd command.
RANDOM Generates a random integer, uniformly distributed between 0 and 32767. The sequence of random numbers can be initialized by assigning a numeric value to the RANDOM variable.
REPLY Set by the select statement and by the read regular built-in command when no arguments are supplied.
SECONDS Specifies the number of seconds since shell invocation is returned. If this variable is assigned a value, then the value returned upon reference will be the value that was assigned plus the number of seconds since the assignment.