[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: How does a pipe works?



Hi

On Mon, 12 Jun 2000, RK Patil wrote:

> Hello,
> The problem pertains to simple shell script. I am unable to analyze the
> follwing ,  can any one on the list explain me :
> 
> The above comand works fine. Now consider this
> 
> $ read var_name  |  echo HELLO
> HELLO
> <here some i/p has to be fed by the user>
> $echo $var_name     # I try to see what the variable has been read into
> <blank line displayed>
> $
When you use pipe, output of leftside command is fed as input to right
side command. So what you are doing in fedding output of 'read var'(which
is none IIRC) is fed as input to 'echo HELLO' which does not require any
output. Obviously var will not contain any value. Pipes are not electrical
wires which can work both ways...(At low frequencies and/or if
echo equalizers are not installed..)

 HTH

 Bye
  Shridhar