I would like to know why this bash script
#!/bin/bash seq 1 3 > foo COUNT=0 while read VAR1; do while read VAR2; do let COUNT++ echo -n $COUNT done < foo done < foo
outputs: 123456789
while this other bash script that (AFAIK) should do the same
#!/bin/bash seq 1 3 > foo COUNT=0 while read VAR1; do cat foo | while read VAR2; do let COUNT++ echo $COUNT done done < foo
outputs: 123123123
source share