read - Read a line from standard input

Synopsis

read [ -r ] [ -p prompt ] [ -u [ n ] ] [ name ... ]

Description

You can use read to read a line and split it into fields using the characters from the IFS variable as delimiters. By default, a backslash (\) at the end of a line causes the line to be continued on the next line. qsh removes both the backslash and the <newline>.

Options

-p prompt
When the interactive option is set, display prompt on stderr.
-r
A backslash at the end of a line does not mean continue the line.
-u n
Read from descriptor n if specified or descriptor 0 by default. The descriptor must be 0 or one that you opened with exec.

Operands

Each name is assigned to the corresponding field from the input line. Any leftover fields are assigned to the last name. The default name is the REPLY variable.

Exit Status

Related information

Examples
  1. Read a line from stdin after displaying a prompt: read -p `Enter a name: ' firstname lastname
  2. Read a line from descriptor 5: read -u5