How to read a line from each of several files in each iteration of a single loop?

前端 未结 2 1615
小蘑菇
小蘑菇 2020-12-21 16:46

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 pas

2条回答
  •  爱一瞬间的悲伤
    2020-12-21 17:10

    I'm not sure how to do it without paste, but you can avoid cut assigning all variables in one read:

    while read -r X Y CHAR; do
        echo "X = $X; Y = $Y; CHAR = $CHAR";
    done < "$file"
    

提交回复
热议问题