I have a file that contains information in two columns:
box1 a1
box2 a2
I'm trying to read this file line by line into read
and have each line items be put into a variable.
On the first pass, $a
would contain box1
and $b
would contain a1
.
On the second pass, $a
would contain box2
and $b
would contain a2
, etc.
An example of the code that I am using to try to achieve is this:
for i in text.txt; do
while read line; do
echo $line | read a b;
done < text.txt;
echo $a $b;
done
This gives me the following results:
box1 a1 box2 a2
When I expected the following results:
box1 a1
box2 a1
How can I fix this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…