How to read from two files in the same time shell

前端 未结 2 986
北海茫月
北海茫月 2021-01-16 10:37

I have two files,

A

john 1 2 3 4 5 6 7
Ely 10 9 9 9 9 9 9
Maria 3 5 7 9 2 1 4
Rox 10 10 10 10 10 10 10

B 
john 7.5
Ely 4.5
Maria 3,7
Rox 8.5
2条回答
  •  春和景丽
    2021-01-16 10:58

    If you really want to read two files at the same time (which doesn't appear to be your actual question -- join is indeed the right tool for what you're doing), you can open them on different FDs:

    while IFS= read -r -u 4 line1 && IFS= read -r -u 5 line2; do
      echo "Line from first file: $line1"
      echo "Line from second file: $line2"
    done 4

提交回复
热议问题