Yesterday I asked also this question. Thanks for all the answers. But I still don't get it.
I did
$ exec 6<&0 0</tmp/lines.txt
I thought: My standard input is redirected now. But the lines in the file are also executed! So is there a default action when you only do this? This is my question.
Let's say
$ cat /tmp/lines.txt
read i j
read i j
echo "i:$i,j:$j">/tmp/res.txt
I do the exec, and after that I do
$ cat /tmp/res.txt
i:read,j:i j
But when I do
$ exec 6<&0 0</tmp/lines.txt;exec 0<&6 6<&-
nothing is read or executed. I can read the lines but now I have to give the action myself,
$ exec 6<&0 0</tmp/lines.txt ;while read i j;do echo "i:$i,j:$j";done
I see in my terminal,
i:read,j:i j
i:read,j:i j
i:echo,j:"i:$i,j:$j">/tmp/res.txt
Thanks again, I hope it is not too long,
Eric J.