[Help-bash] Why using head in different ways will not terminate in the s
From:
Ehsan Hajiramezanali
Subject:
[Help-bash] Why using head in different ways will not terminate in the same time?
Date:
Sat, 26 Mar 2016 23:50:23 -0500
Hi
The following way of calling `head` will terminate as soon as possible:
head -n 1 <(echo 1; sleep 10; seq 10)
However, the original command using the following pipeline does not
work as what I want, i.e. `head` will wait until `sleep` is finished.
(echo 1; sleep 10; seq 10) | head -n 1
It only needs the output from the first echo command. It is
unnecessary that it waits until `sleep` is finished. I am wondering
if this problem is related with the shell or the other things.
Thanks in advance.
Best regards,
Ehsan