Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)

User Commands (p - r) read(1)
NAME
read - Reads one line from the standard input le
SYNOPSIS
read [ -r ] variablename ...
FLAGS
-r Species that the read command treat a \ (backslash) character as just part of the input
line, not as a control character.
DESCRIPTION
The read command reads one line from the standard input le and assigns the values of each
eld in the input line to a shell variable.
The OSS shell contains a built-in command named read that functions in the same way as the
regular OSS command named read, except that a new shell process is started for each execution
of the regular OSS command read. The shell built-in version of read is the default. Both the
regular version and the shell built-in version of the read command are described in this reference
page.
Operands
variablename Species the name of a shell variable.
The rst variable specied by variablename is reached if the line of standard corresponding shell
variables specied is given the value of all the remaining elds. If there are fewer elds than
shell variables, the remaining shell variables are set to empty strings. The setting of shell vari-
ables by the read command affects the current shell execution environment. The environment
variable IFS determines the internal eld separators used to delimit the elds.
The read command prompts for a continuation line when the shell readsan input line ending with
a \ (backslash), unless the -r ag is specied.
Environment Variables
IFS Determines the internal eld separators used to delimit the elds.
EXAMPLES
The following is a command sequence to print a le with the rst eld of each line moved to the
end of the line:
while read -r xx yy
do
printf "%s %s\n" "$yy" "$xx"
done < inputle
NOTES
The OSS read command has both a shell built-in version and a regular version. The two versions
have the same features and function. The only difference between the two versions is that the
shell built-in version does not start a new shell process when it is invoked. Both versions are
described in this reference page. The shell built-in version is the default version. To specify the
regular version, use the full pathname: /bin/read. For more information about shell built-in com-
mands, refer to the sh(1) reference page.
EXIT VALUES
The read command returns the following exit values:
0
>0 An End-of-File was detected or an error occurred during execution.
527188-007 Hewlett-Packard Company 747