Nested while read loops with fd
问题 I'm trying to read from two different inputs in nested loops without success. I've followed the best answer on this question and also took a look at the file descriptors page of the Advanced Bash-Scripting Guide . Sample script I made to test my problem. #!/bin/bash while read line <&3 ; do echo $line while read _line <&4 ; do echo $_line done 4< "sample-2.txt" done 3< "sample-1.txt" Content of sample-1.txt Foo Foo Content of sample-2.txt Bar Bar Expected output Foo Bar Bar Foo Bar Bar The