READ(1)

NAME

read - read a line and assign fields to variables.

SYNOPSIS

read [-r] [-d delimiter] [name ...]
read [-r] [-a array] [-n count | -N count] [-p prompt] [-s] [-t seconds] [name ...]

DESCRIPTION

read reads input and assigns fields to variables using IFS. Without names, it assigns REPLY. The last name receives the unsplit remainder. Without -r, backslashes escape the next character and a backslash-newline pair continues the input line.

-a, -n, -N, -p, -s, and -t are available in Rush's default Bash-compatible mode and are rejected in POSIX mode.

OPTIONS

-a array
Assign all split fields to an indexed array instead of scalar variables.
-d delimiter
Stop at the first byte of delimiter instead of newline.
-n count
Return after at most count characters, or earlier at the input delimiter.
-N count
Read exactly count characters unless end-of-file or a timeout occurs; delimiters do not stop the read.
-p prompt
Write prompt to standard error when standard input is a terminal.
-r
Treat backslashes literally.
-s
Disable terminal echo while reading.
-t seconds
Time out after the given number of seconds; fractional values are accepted. A value of zero probes input readiness without consuming input.
--
End option parsing.

EXIT STATUS

Zero when the delimiter or requested character count is reached, one at end-of-file, 142 on timeout, and two for usage errors.

SEE ALSO

rush-builtins(7), POSIX Shell Command Language.