I hope someone can explain the phenomenon. Because the header indicates that I will learn about file descriptor redirection. Along the way, I came across a question related to the use of the redirection symbol, especially when setting up a constant redirection. I noticed that in some cases it doesn't matter if I use <or >. For example, working with the following script:
#!/bin/bash
exec 3<&0
exec 0<inputFile
while read var
do
echo "$var"
done
exec 0<&3
read -p "Enter a word:" word
echo "$word"
To my surprise, it doesn’t matter if I use >either <in exec 3<&0or operators exec 0<&3. In any of these statements, it seems that if I replace the redirection characters, I still get the same result. It seems obvious to me that making the same types of changes to a string:
exec 0<inputFile
against.
exec 0>inputFile
, STDIN - , STDIN.
, :
< vs >:
exec 3<&0
exec 3>&0
3<&0 vs 0<&3:
exec 3<&0
exec 0<&3
, . .