Domanda

Just a simple question: Why following one-linear not working? How to make IO non blocking?

$ while true; do date; sleep 1; done | tail -f
È stato utile?

Soluzione

The problem is not with non-blocking IO; it's with your choice of tail.

This prints out each line with a colon (all of them):

while true; do date; sleep 1; done | grep :

The problem with tail is that it goes to the last 10 ten lines and then starts following. But in your case, it never reaches the end, so it can't print the last ten.

Altri suggerimenti

If what you want to do is continually replace the last line with the date you could do this:

while true; do echo -en "\r"`date`; sleep 1; done
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top