Question on shell script: continuous processing of tail-f?


Want odd...

Let's say I have a file fall down the numbers:

I want continuously, as new lines, calculate their average. I.e. to output

I don't want to check file periodically, and you want to as soon as the new line came, so once was value. I.e. as tail-f is only c additional logic.
October 8th 19 at 03:04
2 answers
October 8th 19 at 03:06
Our problem. I've been a little dishonest, the line that I called was:
tail-f file.txt | awk '{....morestuff; printf result;}' | awk '{total+=$0;count+=1;print total/count}'

It does not work due to the fact that the first awk buffers the exhaust and not give it a second. Therefore, the right thing to do:
tail-f file.txt | awk '{....morestuff; printf result; <b>fflush()</b>}' | awk '{total+=$0;count+=1;print total/count}'
October 8th 19 at 03:08
Something I don't get it, what is the average you think, if you have the third number is 3, and the fourth is 3.5.
There is 2.5. - javier.Swift commented on October 8th 19 at 03:11
And 3 adjusted to 2, PRSP. - javier.Swift commented on October 8th 19 at 03:14

Find more questions by tags Command line* nix-like systemsbash