Read Values Into a Shell Variable From a Pipe

“I am trying to get bash to process data from stdin that gets piped into, but no luck. What I mean is none of the following work:\r\n\r\n echo "hello world" | test=($(< /dev/stdin)); echo test=$test\r\n test=\r\n\r\n echo "hello world" | read test; echo test=$test\r\n test=\r\n\r\n echo "hello world" | test=cat; echo test=$test\r\n test=\r\n\r\nwhere I want the output to be test=hello world. I've tried putting "" quotes around &quot;$test&quot; that doesn't work either.” <a href=““https://stackoverflow.com/questions/2746553/read-values-into-a-shell-variable-from-a-pipe"">— “ldog”