I need to read from multiple file in one loop. I have one file with X coords, one file with Y coords and one file with chars on those coords.
For now I use paste
to put these files together, and then in a while loop use cut
to separate them like this:
paste x-file y-file char-file | while -r line; do
Y=$(echo "$line" | cut -d -f1)
X=$(echo "$line" | cut -d -f2)
CHAR=$(echo "$line" | cut -d -f3)
done
but the problem with this is that it's really slow (calling cut
again and again).
How should I do this to have in each loop proper values in $Y
, $X
and $CHAR
while speeding things up?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…