On Wed, 9 Oct 2013, Xabier Oneca  --  xOneca wrote:
>
> I am new here, in the list.
>
> I wonder if 'read' can read from pipes, because the following should
> print 'testing' but instead 'got' remains undefined...
>
>   $ echo testing | read got
>   $ echo $got

In your example, variable $got exists only in a subshell.

Are these examples enough to explain why?

$ { echo main shell >&2; echo testing; } | { read got; echo "subshell: $got" 
>&2; }; { echo main shell >&2; echo $got; }

This should as you expect it to.

$ read got <<-EOF
        $(echo testing)
EOF
$ echo $got
testing


Cheers,

-- 
Cristian
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to