Manual page for read(1)
read - read a line from standard input
/usr/bin/read [-r] var ...
read name ...
set variable = $<
read [ -prsu[ n ] ] [ name?prompt ] [ name ... ]
utility will read a single line from standard input.
By default, unless the
option is specified, backslash (\)
acts as an escape character.
If standard input is a terminal device and the invoking shell
will prompt for a continuation line when:
- The shell reads an input line
ending with a backslash, unless the
option is specified.
- A here-document is not terminated after a
The line will be split into fields
as in the shell;
the first field will be assigned to the first
the second field to the second variable
and so forth.
If there are fewer
operands specified than there are fields, the leftover
fields and their intervening separators will be assigned to the last
If there are fewer fields than
will be set to empty strings.
The setting of variables specified by the
operands will affect the current shell execution environment.
If it is called in a subshell or separate utility execution environment,
such as one of the following:
it will not affect the shell variables in the caller's environment.
nohup read ...
find . -exec read ... \;
The standard input must be a text file.
One line is read from the standard input and,
using the internal field separator,
(normally space or tab),
to delimit word boundaries,
word is assigned to the first
the second word
to the second
etc., with leftover words assigned to the last
Lines can be continued using
Characters other than
can be quoted by preceding them with a backslash.
These backslashes are removed before words are assigned to
and no interpretation is done on the character that follows the backslash.
The return code is 0, unless an
set variable = $<
loads one line of standard input as the value for variable.
The shell input mechanism. One line is read and
is broken up into fields using the characters in
as separators. The escape character,
is used to remove any special meaning for the next
character and for line continuation. In raw mode,
character is not treated specially. The first
field is assigned to the first
the second field to the second
etc., with leftover fields assigned to the last
option causes the input line to be taken from the input pipe
of a process spawned by the shell using
flag is present, the input will be saved as a command
in the history file. The flag
can be used to specify a one digit file descriptor unit
to read from. The file descriptor can be opened with the
special command. The default value of
is omitted then
is used as the default
The exit status is
unless the input file is
not open for reading or an end-of-file is encountered.
An end-of-file with the
option causes cleanup for this process so that another
can be spawned. If the first argument contains a
the remainder of this word is used as a
on standard error when the shell is interactive.
The exit status is
unless an end-of-file is encountered.
The following option is supported:
Do not treat a backslash character in any special way.
Consider each backslash to be part of the input line.
The following operand is supported:
The name of an existing or non-existing shell variable.
The following example for
prints a file with the first field of each line moved
to the end of the line.
while read -r xx yy
printf "%s %s\n" "$yy" "$xx"
done < input_file
for descriptions of the following environment variables that affect the
Determine the internal field separators used to delimit fields.
prompt string that an interactive shell
will write to standard error when a
line ending with a backslash is read and the
option was not specified,
or if a here-document is not terminated after a
The following exit values are returned:
End-of-file was detected or an error occurred.
Created by unroff & hp-tools.
© by Hans-Peter Bischof. All Rights Reserved (1997).
Last modified 21/April/97