help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] How not to wait for the inputs finish if a program does not


From: Ehsan Hajiramezanali
Subject: [Help-bash] How not to wait for the inputs finish if a program does not need to see all the input?
Date: Fri, 25 Mar 2016 16:40:19 -0500

Hi,

If one runs the following examples, both head and awk will wait until
`sleep` is finished.

(echo 1; sleep 10; seq 10) | head -n 1
(echo 1; sleep 10; seq 10) | awk -e 'NR==1{print $1;exit}'

However, they only need the output from the first echo command. It is
unnecessary that they wait until `sleep` is finished. I am wondering
if this problem is related with the shell or the programs head/awk.

How one might let head and awk finish as soon as they see the first line?

Thanks in advance.

Best regards,
Ehsan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]