Why does the following work from the prompt but fail when stuck inside a bash script? The bash script produces one empty line leading me to believe the variable isn't being set:
echo "red sox" | read my_var
echo $my_var
UPDATE: Since I guess my example isn't working, what I'm really trying to do is take I/O and pipe it into a variable to so I can do things with it. How do I do this? I thought this should be taken care of by the read
command, but maybe there's another way?