Bourne to read?

Scott W. Adkins sadkins at oucsace.cs.OHIOU.EDU
Sat Mar 2 02:04:56 AEST 1991


In article <1991Feb28.160948.24987 at hoss.unl.edu> mosemann at sardion.unl.edu (Russell Mosemann) writes:
>
>   In the Bourne shell, why does this not work
>
>      echo words | read W
>
>   but this does (if I put the words in the file)
>
>      read W < file

Well, it could be a matter of where things are coming from and where they are
going to.  In the first case, echo words is sending the stuff to stdout, not
stdin.  The read W is waiting for input from stdin, not stdout.  Result?  The
words will be echoed to the screen and then the script will wait for keyboard
input.

In the second example, the '<' symbol literally means redirect the output of
this file to this other file.  In other words, file is redirected to stdin
of read W.  I hope this helps.  If I am wrong on these accounts, I will be
watching for the correct solution.

Scott Adkins
sadkins at oucsace.cs.ohiou.edu



More information about the Comp.unix.questions mailing list