COHERENT manpages

This page displays the COHERENT manpage for read [Assign values to shell variables].

List of available manpages
Index


read -- Command

Assign values to shell variables
read name ...

read reads  a line from the  standard input.  It assigns  each token of the
input to the corresponding shell variable name. If the input contains fewer
tokens than the number of names  specified, read assigns the null string to
each extra variable.  If the input  contains more tokens than the number of
names specified,  read assigns the last  name in the list  the remainder of
the input.

read normally returns an exit status of zero.  If it encounters end of file
or is interrupted while reading the standard input, it returns one.

The shell executes read directly.

Example

The command

    read foo bar baz
    hello how are you

parses  the  line  ``hello  how  are  you''  and  assigns  the  tokens  to,
respectively, the shell variables foo, bar, and baz. If you further type

    echo $foo
    echo $bar
    echo $baz

you will see:

    hello
    how
    are you

See Also

<a href="manpage.php?page=commands"><b>commands,b>a>
<a href="manpage.php?page=ksh"><b>ksh,b>a>
<a href="manpage.php?page=sh"><b>shb>a>