Accessing the output of a Bash pipe with 'read'
Posted
by
Karthik
on Super User
See other posts from Super User
or by Karthik
Published on 2010-08-08T02:39:13Z
Indexed on
2012/10/01
15:43 UTC
Read the original article
Hit count: 609
I'm trying to pipe some data from a Bash pipe into a Bash variable using the read command, like this:
$ echo "Alexander the Grape" | read quot
$ echo $quot
$
But quot is empty. Some Googling revealed that this is not a bug; it's an intended feature of Bash. (Section E5 in the FAQ.)
But when I tried the same thing in zsh, it worked. (Ditto for ksh.) Is there any way to make this work in Bash? I really don't want to have to type:
$ quot=$(echo "Alexander the Grape")
Especially for long commands.
© Super User or respective owner