

read                         Command                         read




Assign values to shell variables

rreeaadd _n_a_m_e ...

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 in-
put contains more tokens than the number of names specified, read
assigns the last name in the list the remainder of the input.

The shell sh 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 fur-
ther type


        echo $foo
        echo $bar
        echo $baz


you will see:


        hello
        how
        are you


***** See Also *****

commands, sh

***** Diagnostics *****

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







COHERENT Lexicon                                           Page 1


