Pipes vs I/O redirection

Started by Alvin Seville, November 11, 2020, 10:28:51 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Alvin Seville

Hello! Can somebody tell my why first code works as expected:

echo 1 | { read x; echo $x; }

and the second one doesn't:

echo 1 >&0; read x; echo $x;

? I expect 1 outputted but in second case I have to press return before it.

- Best regards, Alvin Seville.