What does the following script mean?
exec 4<&0 0</etc/XX/cfg read line1 exec 0<&4
It redirects fd0 to fd4, and "/etc/XX/cfg" to fd0.
So why does
read still work, shouldn't that be empty?
It redirects stdin (FD0) to FD4, redirects from
To recast this in syscalls (using C):
The way I read this - based on the bash manpage section on REDIRECTION - is that
A demo might show my meaning a little better and answer "why" you might do this. By adding another line and putting it in a wrapper:
You can pipe or redirect
Hopefully this explains it.
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?