This question already has an answer here:
Say I have a loop that goes through a file line-by-line via
read. I would like to have both the original line, and the line split into different variables, which
read does nicely. However, I can't seem to echo a variable, pipe it to
read, and have the variables populated. Here's a base case:
echo "a b c d e f g" | read line echo "Read obtained: $line"
How can I make read do what I want? Or: Why am I wrong to ask read to do this, and what should I do instead?