I'm trying to use this one-liner that should print all the lines that are being added to the file /var/log/messages.log
.
sudo tail -f /var/log/messages.log | python2 -c 'exec("import sys\n\nfor line in sys.stdin:\n\tprint line")'
For readability, the python code is:
import sys
for line in sys.stdin:
print line
If I add a single line to /var/log/messages.log
, I don't see anything getting printed. But, if I add lots of data, I start getting output.
Is there a defined behaviour as to how often the generator sys.stdin
generate data
?
PS: My end-goal is to understand the one-liner that outputs the number of lines that are being fed to the python program per second.
EDIT: How is it assumed that interpreter will cross this line if t > e:
every one second?