1
0
Files
irix-657m-src/eoe/man/man1/read.1
2022-09-29 17:59:04 +03:00

103 lines
3.1 KiB
Groff

'\"macro stdmacro
.if n .pH g1.read @(#)read 30.2 of 12/25/85
.nr X
.if \nX=0 .ds x} read 1 "Essential Utilities" "\&"
.if \nX=1 .ds x} read 1 "Essential Utilities"
.if \nX=2 .ds x} read 1 "" "\&"
.if \nX=3 .ds x} read "" "" "\&"
.ds OK [\|
.ds CK \|]
.TH \*(x}
.SH NAME
\f3read\f1 - read a line from standard input
.SH SYNOPSIS
\f3read\f1 [-r] var...
.SH DESCRIPTION
The \f3read\f1 utility will read a single line from standard input.
.PP
By default, unless the \f3-r\f1 option is specified, backslash (\) acts as an
escape character. If
standard input is a terminal device and the invoking shell is
interactive, \f3read\f1 will prompt for a continuation line when:
.IP
The shell reads an input line ending with a backslash, unless the \f3-r\f1
option is specified.
.IP
A here-document is not terminated after a newline character is entered.
.PP
The line will be split into fields as in the shell;
the first field will be assigned to the first variable var, the
second field to the second variable var, and so on. If there are fewer
var operands specified than there are fields, the leftover fields and
their intervening separators will be assigned to the last var. If there
are fewer fields than vars, the remaining vars will be set to empty
strings.
.PP
The setting of variables specified by the var operands will affect the
current shell execution environment; see Shell Execution Environment.
If it is called in a subshell or separate utility execution
environment, such as one of the following:
.IP
.nf
(read foo)
nohup read ...
find . -exec read ... \\;
.fi
.PP
it will not affect the shell variables in the caller's environment.
.SH OPTIONS
The \f3read\f1 utility supports the XBD specification, Utility Syntax
Guidelines.
.PP
The following option is supported:
.TP 6
\f3-r\f1
Do not treat a backslash character in any special way. Consider each
backslash to be part of the input line.
.SH OPERANDS
The following operands are supported:
.TP 6
var
The name of an existing or non-existing shell variable.
.SH STDIN
The standard input must be a text file.
.SH ENVIRONMENT VARIABLES
The following environment variables affect the execution of read:
.TP 6
\f3IFS\f1
Determine the internal field separators used to delimit fields.
.TP 6
\f3PS2\f1
Provide the prompt string that an interactive shell will write to
standard error when a line ending with a backslash is read and the \f3-r\f1
option was not specified, or if a here-document is not terminated after
a newline character is entered.
.SH EXIT STATUS
.TP 6
The following exit values are returned:
0
Successful completion.
>0
End-of-file was detected or an error occurred.
.SH APPLICATION USAGE
The \f3read\f1 utility has historically been a shell built-in.
.PP
The \f3-r\f1 option is included to enable read to subsume the purpose of the
line utility, which has been marked LEGACY.
.PP
The results are undefined if an end-of-file is detected following a
backslash at the end of a line when \f3-r\f1 is not specified.
.SH EXAMPLES
The following command:
.IP
.nf
while read -r xx yy
do
printf "%s %s\n" "$yy" "$xx"
done < input_file
.PP
prints a file with the first field of each line moved to the end of the
line.
.SH SEE ALSO
\f3sh(1).\f1