bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: echo thing | read thang


From: Chris F.A. Johnson
Subject: Re: echo thing | read thang
Date: Thu, 02 Aug 2001 03:22:32 GMT

On Wed, 1 Aug 2001, Paul Jarc wrote:

> Philip Lijnzaad <lijnzaad@ebi.ac.uk> writes:
> > (I was actually exploring why on earth echo foo | read bar; echo $bar does
> > not work; I consider this a bug as well, perhaps not as 'blatant' as the
> > above one, but puzzling nonetheless).
>
> See question E4 in the FAQ; each command in a pipeline is run in a
> separate process, so the process that performs the "read" commands is
> not the process that performs the subsequent "echo" command.  You may
> find this useful: read var < <(command)

Or:

cmd1 | {
        while read var
        do
            var1="$var $var1"
        done
        echo $var1
        }

All the commands within the braces are executed in the same subshell.

-- 
        Chris F.A. Johnson          bq933@torfree.net
        =================================================================
        c.f.a.johnson@home.com      http://cfaj.freeshell.org
        cfaj@freeshell.org          http://members.home.net/c.f.a.johnson



reply via email to

[Prev in Thread] Current Thread [Next in Thread]