Bash script, read values from stdin pipe
Posted
by gmatt
on Stack Overflow
See other posts from Stack Overflow
or by gmatt
Published on 2010-04-30T17:51:55Z
Indexed on
2010/04/30
17:57 UTC
Read the original article
Hit count: 371
I'm trying to get bash to process data from stdin that gets piped it, but no luck, what I mean is none of the following work:
echo "hello world" | test=($(< /dev/stdin)); echo test=$test
test=
echo "hello world" | read test; echo test=$test
test=
echo "hello world" | test=`cat`; echo test=$test
test=
where I want the output to be test=hello world
. Note I've tried putting "" quotes around "$test"
that doesn't work either.
© Stack Overflow or respective owner