Quantcast
Channel: Read / write to the same file descriptor with shell redirection - Unix & Linux Stack Exchange
Browsing all 3 articles
Browse latest View live

Answer by Stéphane Chazelas for Read / write to the same file descriptor with...

In { err=$(exec 2>&1 >&3; ls -ld /x /bin); exec 0<&3; out=$(cat); } 3>&1 The { ... } 3>&1 clones the fd 1 to fd 3. That just means that fd 3 now points to the same...

View Article



Answer by glenn jackman for Read / write to the same file descriptor with...

It seems like a basic limitation of the variable assignment syntax, and the side-effects of the shell spawning subshells. You can either capture stderr or stdout but not both: the other stream needs to...

View Article

Read / write to the same file descriptor with shell redirection

I'm trying to understand file descriptors in the context of shell redirection. Why can't I have cat read from FD 3, which is being written to by ls's STDOUT? { err=$(exec 2>&1 >&3; ls...

View Article
Browsing all 3 articles
Browse latest View live




Latest Images